Skip to main content
POST
/
api
/
v2
/
platform
/
digitals
Create a Digital Asset
const form = new FormData();
form.append('digital[attachment]', '<string>');
form.append('digital[variant_id]', '123');

const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

options.body = form;

fetch('http://{defaultHost}/api/v2/platform/digitals', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "data": {
    "id": "24",
    "type": "digital",
    "attributes": {
      "url": "/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBLUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--6cac9cd14eb0139474e42d68585bead023589c85/icon_256x256.jpg",
      "content_type": "image/png",
      "filename": "icon_256x256.jpg",
      "byte_size": 818
    },
    "relationships": {
      "variant": {
        "data": {
          "id": "94",
          "type": "variant"
        }
      }
    }
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

include
string

Select which associated resources you would like to fetch, see: https://jsonapi.org/format/#fetching-includes

Body

multipart/form-data
digital[attachment]
file
required
digital[variant_id]
string
required
Example:

"123"

Response

Record created

data
object
required