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. You can also list every design the customer has made. Each call takes 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. The answer carries its timing, so you can show the customer a countdown.
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", "timing": { "elapsed_ms": 1840, "expected_ms": 35488 }, "images": []}Retrieve a design
Answers the design with its images once they are ready. Send the same two headers. Ask every few seconds while the status is processing. Its timing says how long the design has run and how long designs take now: most take about 30 seconds, and some 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", "timing": null, "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" } ]}List designs
Returns the customer's designs, newest first, one page at a time. Each one is the same object that Retrieve a design returns, with all its images, including the ones the customer didn't make a project from.
https://api.diamra.com/v1/designsSend the same two headers. The parameters go in the query string, and each one is optional.
curl -G https://api.diamra.com/v1/designs \ -H "Authorization: Bearer $DIAMRA_API_KEY" \ -H "Diamra-Customer-Token: $ACCESS_TOKEN" \ -d limit=1HTTP/2 200content-type: application/jsonrequest-id: req_6d2a9f41c7e05b38{ "object": "list", "url": "/v1/designs", "has_more": true, "data": [ { "id": "3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90", "status": "succeeded", "timing": null, "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" } ] } ]}has_more is true when more designs follow. For the next page, send the last design's id as starting_after, with the same limit and has_project.
curl -G https://api.diamra.com/v1/designs \ -H "Authorization: Bearer $DIAMRA_API_KEY" \ -H "Diamra-Customer-Token: $ACCESS_TOKEN" \ -d limit=1 \ -d starting_after=3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90When has_more is false, you have them all. A customer with no designs gets an empty data list.
The design
Create a design and Retrieve a design answer it. List designs answers a page of them in data.
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. List designs answers a 429 rate_limit, with Retry-After: 60. Retrieve a design has no limit.
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." }}