Designs
Make jewelry designs from what a customer describes in words, photos of pieces they like, or both. Your server sends them 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" }'curl 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": "The same ring in yellow gold", "reference_images": [ { "id": "7c2e9a41-5d3b-4f8e-a1c6-0b9d4e2f8a73" } ] }'HTTP/2 202content-type: application/jsonrequest-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 200content-type: application/jsonrequest-id: req_2e9b47d1a0c35f68{ "id": "3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90", "status": "succeeded", "images": [ { "id": "4a8c2e6f-1b3d-4f5a-9c7e-0d2b4f6a8c10", "url": "https://assets.diamra.com/design-images/3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90/0.webp" }, { "id": "5b9d3f70-2c4e-4a6b-8d0f-1e3c5a7b9d21", "url": "https://assets.diamra.com/design-images/3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90/1.webp" }, { "id": "6cae4081-3d5f-4b7c-9e1a-2f4d6b8cae32", "url": "https://assets.diamra.com/design-images/3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90/2.webp" }, { "id": "7dbf5192-4e6a-4c8d-af2b-3a5e7c9dbf43", "url": "https://assets.diamra.com/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 429content-type: application/jsonretry-after: 10800request-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." }}