Designs
Make jewelry designs from what a customer describes in words. Your server sends the description and gets the design's id at once. About 30 seconds later the design has its images, usually four, and you fetch them by that id. Both calls take your API key and the customer's access token from Auth. Each design belongs to that customer, in your store. The API comes with the Retail plan.
Create a design
Starts the design and answers within a few seconds, before the images exist.
https://api.diamra.com/v1/designscurl https://api.diamra.com/v1/designs \
-H "Authorization: Bearer $DIAMRA_API_KEY" \
-H "Diamra-Customer-Token: $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "prompt": "A rose gold ring with an oval sapphire and a thin pavé band" }'HTTP/2 202
content-type: application/json
request-id: req_5c0e2b8a41f97d36
{
"id": "3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90",
"status": "processing",
"images": []
}Retrieve a design
Answers the design with its images once they are ready. Send the same two headers. Ask every few seconds until the status is no longer processing: most designs take about 30 seconds, and some take up to two minutes.
https://api.diamra.com/v1/designs/{id}curl https://api.diamra.com/v1/designs/3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90 \
-H "Authorization: Bearer $DIAMRA_API_KEY" \
-H "Diamra-Customer-Token: $ACCESS_TOKEN"HTTP/2 200
content-type: application/json
request-id: req_2e9b47d1a0c35f68
{
"id": "3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90",
"status": "succeeded",
"images": [
{ "url": "https://yrhslqqtzvvlsgnoegue.supabase.co/storage/v1/object/public/design-images/3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90/0.webp" },
{ "url": "https://yrhslqqtzvvlsgnoegue.supabase.co/storage/v1/object/public/design-images/3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90/1.webp" },
{ "url": "https://yrhslqqtzvvlsgnoegue.supabase.co/storage/v1/object/public/design-images/3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90/2.webp" },
{ "url": "https://yrhslqqtzvvlsgnoegue.supabase.co/storage/v1/object/public/design-images/3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90/3.webp" }
]
}The design
Both calls answer it.
When a design fails, create it again. Some descriptions can't be made into a design, so if it fails a second time, ask the customer to describe the piece another way.
Your store's settings
What you set for your store in your Bench applies to every design made through the API:
- The Instructions and Engraving under Branding go into every design, and Watermark Designs, when it's on, puts your logo on the images.
- The Per-user quota under Billing caps how many designs one customer can make in 24 hours.
- If your store approves new customers first, a customer you haven't approved yet gets 403 access_pending.
Limits
Over a limit, the POST answers a 429: rate_limit for too many designs in a short time, customer_quota once the customer has used your quota. When the wait is known, a Retry-After header gives it in seconds.
Errors
HTTP/2 429
content-type: application/json
retry-after: 10800
request-id: req_7a1d3e95c02b4f86
{
"error": {
"type": "invalid_request_error",
"code": "customer_quota",
"message": "This customer has made as many designs as your store allows one customer in 24 hours."
}
}