Embed a Design
This guide will walk you through how to embed a design using the Core3D Embed APIs.
$TOKEN
as a placeholder for your API token in the examples below.Contents
- Step 1 — Choose a Design
- Step 2 — Request the HTML
- Step 3 — Generate a Token
- Step 4 — View the Result
Step 1 — Choose a Design
We'll use the Design generated in our previous guide as an example. The URI for that Design is core3d:design:018d715f-b81f-79e7-a942-c9e4f3f5f1cc
.
Step 2 — Request the HTML
We can request HTML from the Core3D API that we can drop onto our website to display the 3D model.
- Request
- Response
$ curl -X POST https://api.core3d.io/embed/iframe/v1 \-H "Authorization: Bearer $TOKEN" \-H "Content-Type: application/json" \-d '{"uri": "core3d:design:018d715f-b81f-79e7-a942-c9e4f3f5f1cc"}'
Step 3 — Generate a Token
We'll need to replace the $TOKEN
string in the response with a real API token. Exposing a token with read
or write
access in any public context is dangerous -- if the token is visible in your source code it can be extracted and used to view or manipulate resources in your Core3D account. To avoid this, we'll generate a token that meets the following criteria:
- is assigned only the
embed
capability, which provides very limited access to Core3D API resources - has an explicit
origin
allowlist, to prevent it from working on any other origins
- Request
- Response
$ curl -X POST https://api.core3d.io/v1/tokens \-H "Authorization: Bearer $TOKEN" \-H "Content-Type: application/json" \-d '{"capabilities": ["embed"],"origins": ["https://www.core3d.io"],"type": "api","user": "~"}'
Step 4 — View the Result
After replacing the $TOKEN
parameter with our new embed
token we can view the result.