Skip to content

API: Artisans

Endpoints for managing artisan profiles.

Base path

/artisans

Endpoints

GET /artisans

List all artisans.

Request:

No parameters.

Response:

StatusDescriptionBody
200Artisan list{ artisans: [...] }

Response body — artisans[]:

FieldTypeDescription
idnumberArtisan ID
namestringArtisan's full name
photoUrlstringFull public URL of the photo
phonestring | nullPhone number (digits only)
emailstring | nullContact email
descriptionstring | nullBio or description

Business rules:

  • Returns all non-deleted artisans.
  • Returns an empty array when no artisans exist.

POST /artisans

Register a new artisan. The backend generates an R2 object key and a presigned URL for the photo. The client uploads the file directly to R2 using the returned presigned URL.

Request:

LocationFieldTypeRequiredDescription
bodynamestringyesArtisan's full name (max 255 chars)
bodyphoto.mimeTypestringyesPhoto MIME type — image/png or image/jpeg
bodyphonestringnoPhone number — digits only, exactly 11 digits
bodyemailstringnoValid email address
bodydescriptionstringnoBio or description of the artisan's work

Response:

StatusDescriptionBody
201Artisan created{ id, name, photoUrl, presignedUrl, phone, email, description }
400Validation error{ message: string }

Business rules:

  • photo.mimeType must be one of: image/png, image/jpeg.
  • phone must contain only digits and be exactly 11 characters.
  • email must be a valid email address.
  • At least one of phone or email must be provided.
  • photoUrl in the response is the full public URL (R2_PUBLIC_URL + object_key).
  • presignedUrl is a temporary presigned PUT URL for the client to upload the photo directly to R2.