Projects
A project is a piece your customer wants made, started from one of a design's images. It opens on your Bench, where your team takes it from an estimate to the finished piece. Your server creates a project when the customer picks an image, reads it back with its measurements, lists and searches the customer's projects, and deletes one if they change their mind. Every call takes your API key and the customer's access token from Auth. Each project belongs to that customer, in your store. The API comes with the Retail plan.
Create a project
Starts a project from the image the customer picked. Its id is in the design's images, which Retrieve a design returns.
https://api.diamra.com/v1/projectscurl https://api.diamra.com/v1/projects \ -H "Authorization: Bearer $DIAMRA_API_KEY" \ -H "Diamra-Customer-Token: $ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "design_image": { "id": "6cae4081-3d5f-4b7c-9e1a-2f4d6b8cae32" } }'HTTP/2 201content-type: application/jsonrequest-id: req_1f8c3a6e94d27b05{ "id": "8d3e5b17-2f6a-4c9e-b0d4-7a1c9e2f6b58", "design_image": { "id": "6cae4081-3d5f-4b7c-9e1a-2f4d6b8cae32", "url": "https://assets.diamra.com/design-images/3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90/2.webp" }, "projections": []}An image has one project. If the image has a project already, the call answers it with a 200 and starts nothing new. A new project sends the project.started webhook event, like every new project in your store. Diamra also emails your team about it, unless you turned that email off in Diamra Email Delivery.
Retrieve a project
Returns the project with its projections. When a project starts, Diamra draws the piece from the front, the top, the left and the bottom so it can be measured. The projections take about a minute, and until then the list is empty. Your team measures the piece by drawing lines over them on your Bench, and the customer can too if your store lets them. Each projection lists those lines as its measurements.
https://api.diamra.com/v1/projects/{id}Send the same two headers.
curl https://api.diamra.com/v1/projects/8d3e5b17-2f6a-4c9e-b0d4-7a1c9e2f6b58 \ -H "Authorization: Bearer $DIAMRA_API_KEY" \ -H "Diamra-Customer-Token: $ACCESS_TOKEN"HTTP/2 200content-type: application/jsonrequest-id: req_7b2e0c5d18f94a63{ "id": "8d3e5b17-2f6a-4c9e-b0d4-7a1c9e2f6b58", "design_image": { "id": "6cae4081-3d5f-4b7c-9e1a-2f4d6b8cae32", "url": "https://assets.diamra.com/design-images/3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90/2.webp" }, "projections": [ { "view": "front", "url": "https://assets.diamra.com/measure-projections/5b8e1f3a-2c47-4d9e-b061-7a3f9c2e4d18/8d3e5b17-2f6a-4c9e-b0d4-7a1c9e2f6b58/front/2b7e4c90-6a1d-4f3b-8e5c-9d0a1b2c3e4f.webp", "measurements": [ { "type": "reference", "label": "total setting height", "mm": 10, "text": null, "from": { "x": 0.2814, "y": 0.2367 }, "to": { "x": 0.2814, "y": 0.7712 } }, { "type": "measurement", "label": "center stone major axis", "mm": 5.4, "text": null, "from": { "x": 0.3712, "y": 0.3105 }, "to": { "x": 0.6288, "y": 0.3105 } }, { "type": "measurement", "label": "shank thickness", "mm": 1.6, "text": null, "from": { "x": 0.4875, "y": 0.7104 }, "to": { "x": 0.4875, "y": 0.7871 } }, { "type": "callout", "label": "bezel", "mm": null, "text": "14K yellow gold", "from": { "x": 0.6633, "y": 0.3519 }, "to": { "x": 0.8211, "y": 0.2042 } } ] }, { "view": "top", "url": "https://assets.diamra.com/measure-projections/5b8e1f3a-2c47-4d9e-b061-7a3f9c2e4d18/8d3e5b17-2f6a-4c9e-b0d4-7a1c9e2f6b58/top/2b7e4c90-6a1d-4f3b-8e5c-9d0a1b2c3e4f.webp", "measurements": [ { "type": "measurement", "label": "center stone minor axis", "mm": 3.8, "text": null, "from": { "x": 0.4093, "y": 0.5 }, "to": { "x": 0.5907, "y": 0.5 } } ] }, { "view": "left", "url": "https://assets.diamra.com/measure-projections/5b8e1f3a-2c47-4d9e-b061-7a3f9c2e4d18/8d3e5b17-2f6a-4c9e-b0d4-7a1c9e2f6b58/left/2b7e4c90-6a1d-4f3b-8e5c-9d0a1b2c3e4f.webp", "measurements": [] }, { "view": "bottom", "url": "https://assets.diamra.com/measure-projections/5b8e1f3a-2c47-4d9e-b061-7a3f9c2e4d18/8d3e5b17-2f6a-4c9e-b0d4-7a1c9e2f6b58/bottom/2b7e4c90-6a1d-4f3b-8e5c-9d0a1b2c3e4f.webp", "measurements": [] } ]}A reference is a length someone entered, and it sets the scale. Measurements are worked out from it, and a line with no length yet isn't listed. A callout is a note, such as the metal or a stone's weight. Lengths are in millimeters, to 0.1 mm.
Each line has two points on the projection's image, from and to. Their x and y are fractions of the image's width and height from its top-left corner, so multiply them by the image's size in pixels to draw the line. For a length they are its two ends. For a callout, from is the point it marks and to is where its note sits. A line drawn past the image's edge can go below 0 or above 1.
Delete a project
Takes the project off the customer's projects. Nothing is lost: your store keeps it on your Bench, with its projections and everything else made for it.
https://api.diamra.com/v1/projects/{id}Send the same two headers.
curl -X DELETE https://api.diamra.com/v1/projects/8d3e5b17-2f6a-4c9e-b0d4-7a1c9e2f6b58 \ -H "Authorization: Bearer $DIAMRA_API_KEY" \ -H "Diamra-Customer-Token: $ACCESS_TOKEN"HTTP/2 200content-type: application/jsonrequest-id: req_6a0d4e2b71f93c58{ "id": "8d3e5b17-2f6a-4c9e-b0d4-7a1c9e2f6b58", "deleted": true}Deleting it again answers 404, and so does retrieving it. To bring it back, create a project from the same image: the same project comes back, with its id, its projections and their measurements.
List projects
Returns the customer's projects, newest first, one page at a time. Each one is the same object that Retrieve a project returns. Deleted projects aren't listed.
https://api.diamra.com/v1/projectsSend the same two headers. The parameters go in the query string, and each one is optional.
curl -G https://api.diamra.com/v1/projects \ -H "Authorization: Bearer $DIAMRA_API_KEY" \ -H "Diamra-Customer-Token: $ACCESS_TOKEN" \ -d limit=1 \ --data-urlencode "search=oval sapphire"HTTP/2 200content-type: application/jsonrequest-id: req_9c4a1e7f30b2d865{ "object": "list", "url": "/v1/projects", "has_more": true, "data": [ { "id": "9e4f6c28-3a7b-4d0f-8c1e-5b2d0a3f7c69", "design_image": { "id": "7dbf5192-4e6a-4c8d-af2b-3a5e7c9dbf43", "url": "https://assets.diamra.com/design-images/3f6d1c2e-8a4b-4f0e-9b7a-2c5e8d1f4a90/3.webp" }, "projections": [] } ]}has_more is true when more projects follow. For the next page, send the last project's id as starting_after, with the same limit and search.
curl -G https://api.diamra.com/v1/projects \ -H "Authorization: Bearer $DIAMRA_API_KEY" \ -H "Diamra-Customer-Token: $ACCESS_TOKEN" \ -d limit=1 \ --data-urlencode "search=oval sapphire" \ -d starting_after=9e4f6c28-3a7b-4d0f-8c1e-5b2d0a3f7c69When has_more is false, you have them all. A search that matches nothing returns an empty data list.
The project
Create a project and Retrieve a project answer it, and List projects returns a page of them in data. Delete a project answers its id and deleted: true.
Limits
Over a limit, the call answers a 429 rate_limit, with Retry-After: 60, and the message says which. Retrieve a project and Delete a project have no limit.
Errors
HTTP/2 400content-type: application/jsonrequest-id: req_3c7e1b94a05d2f86{ "error": { "type": "invalid_request_error", "code": "resource_missing", "message": "No design image 7c2e9a41-5d3b-4f8e-a1c6-0b9d4e2f8a73 of this customer in your store.", "param": "design_image.id" }}