Diamra Developer Docs
All pages

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.

POSThttps://api.diamra.com/v1/designs
HeaderWhat it is
Authorization
Required. Bearer and your API key.
Diamra-Customer-Token
Required. The customer's access_token from Log in, Register or Refresh.
ParameterWhat it is
prompt
The piece the customer wants, in their words, up to 1,000 characters. Required unless you send reference_images.
reference_images
Up to ten photos of pieces the customer likes, one object each, in the order the customer chose them. The design stays close to the piece in the photos. Each one is an image this customer sent in your store, or a product from your store's catalog.
reference_images[].id
The image's id from Images. Send this or catalog_product in each object.
reference_images[].catalog_product
A product from your store's catalog, as an object with its id. The design follows the product's photo, and Diamra keeps no copy of it.
RequestShell
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": "A rose gold ring with an oval sapphire and a thin pavé band"  }'
Request with an imageShell
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"      }    ]  }'
ResponseHTTP
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.

GEThttps://api.diamra.com/v1/designs/{id}
RequestShell
curl https://api.diamra.com/v1/designs/3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90 \  -H "Authorization: Bearer $DIAMRA_API_KEY" \  -H "Diamra-Customer-Token: $ACCESS_TOKEN"
ResponseHTTP
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.

GEThttps://api.diamra.com/v1/designs

Send the same two headers. The parameters go in the query string, and each one is optional.

ParameterWhat it is
limit
How many designs to return, from 1 to 100. The default is 10.
starting_after
The id of the last design on the page you have. The next page starts after it.
has_project
true returns only the designs with an image that is one of the customer's projects. false returns only the designs with none. Leave it out to get every design.
RequestShell
curl -G https://api.diamra.com/v1/designs \  -H "Authorization: Bearer $DIAMRA_API_KEY" \  -H "Diamra-Customer-Token: $ACCESS_TOKEN" \  -d limit=1
ResponseHTTP
HTTP/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.

The next pageShell
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-2c5e8d1f4a90

When 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.

FieldWhat it is
id
The design's id.
status
processing while the images are made, then succeeded or failed.
timing
While the status is processing: elapsed_ms, how long the design has run, and expected_ms, how long designs take now. null after that. See Calls that take time.
images
Once the design has succeeded, its images in order, usually four. Empty before that, and when it failed.
images[].id
The image's id. Send it as design_image.id to create a project from this image.
images[].url
A public link to a square WebP image that you can show on your website. It needs no key. The image behind a link never changes, so browsers can cache it for good. The links are on assets.diamra.com: if your site sets a Content-Security-Policy, add that host to img-src.

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

One customer
10 designs in 10 seconds, and your Per-user quota in 24 hours.
Your store
120 calls a minute to List designs.

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

AnswerWhen
400 parameter_missing
No prompt and no reference images.
400 parameter_unknown
A parameter the call doesn't take, often a typo. param names it.
400 parameter_invalid
The prompt isn't a string or is longer than 1,000 characters, or reference_images isn't a list of up to ten objects, each with a different image id or catalog product, and never both in one object. On List designs: limit isn't a whole number from 1 to 100, starting_after isn't a well-formed id, or has_project isn't true or false. param names the one at fault.
400 resource_missing
An id in reference_images isn't an image this customer sent in your store, or a catalog_product isn't in your store's catalog. param names it, such as reference_images[1].id, and the message gives the id. On List designs: starting_after isn't one of this customer's designs in your store.
400 catalog_not_connected
reference_images names a catalog product, and your store has no catalog connected.
401 api_key_invalid
No key, or one Diamra doesn't know. See API keys.
401 api_key_revoked
The key was revoked in your console.
401 customer_token_invalid
No access token, or one that ran out or was never valid. Refresh the session, or log the customer in again.
403 access_pending
Your store approves new customers first and hasn't approved this one. Approve them under Customers in your Bench.
403 plan_required
Your store isn't on the Retail plan. Its keys work again once it is.
404 resource_missing
No design with this id belongs to this customer in your store.
429 customer_quota
The customer has made as many designs in 24 hours as your Per-user quota allows. Retry-After says when they can make more.
429 rate_limit
Too many designs in a short time, or more than 120 calls to List designs in a minute for your store.
503
The design couldn't be started. Try again in a minute.
503 catalog_unavailable
Your store's catalog didn't answer when Diamra looked up a product. Try again in a minute.
An errorHTTP
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."  }}