Create asset
What is an asset?
When creating an asset through the Original API you essentially mint a token (defined by metadata associated to your digital item) on the blockchain directly to one of your user's wallet.
For more info about the wallets, refer to the section wallets and security.
Create an asset
Important:
Request headers are required. See API basics introduction for more information.
Endpoint
POST /asset
- Creates a new
asset
associated with the given App and User (set by the X-API-KEY). - Returns a new
asset
(asset uid
) associated with the given app and user.
Note:
The request is partly asynchronous - the response will immediately return the
asset uid
and mint the underlying NFT on the blockchain asynchronously for the givenuser_uid
's wallet.To know when the
asset
has been minted, you can subscribe to the Webhook events or poll any Get asset endpoint.
Request body
Request body fields | Type | Description | Required/Optional |
---|---|---|---|
user_uid | String | The UID for the user of the App. | Required |
collection_uid | String | The collection UID to which the asset will be minted. | Required |
asset_external_id | String | The unique ID by which you identify this asset in your system. | Required |
sale_price_in_usd | Number | The sale price of the asset being created. This will be used for displaying analytics | Optional |
data | Object | The data associated with the asset. | Required |
- name | String | The name of the asset. | Required |
- unique_name | Boolean | Whether the asset name should be unique or not. * | Required |
- image_url | String (URL) | The image url of the asset. | Required |
- store_image_on_ipfs | Boolean | Whether the image should be stored on IPFS. ** | Required |
- description | String | A description of the asset. | Optional |
- external_url | String (URL) | An external URL for additional information. | Optional |
- attributes | Array of Objects | Additional attributes describing the asset. | Optional |
-- trait_type | String | The type of trait or attribute. | Required |
-- value | String | The value of the trait or attribute. | Required |
-- display_type | String | The display type for the attribute value. | Optional |
Tips
In the context of Creating an asset:
user_uid
refers to the user UID that the asset is to be minted to (UID we return when you create a user)asset_external_id
refers to your own unique identifier in your system to identify the asset
Note
*unique_name:
- If set to True, we will check for existing names and return an error "Asset with this name already exists" as a guard from creating two assets with the same name for the same collection.
- If set to False, we will append
#TOKEN_ID
to the name.**store_image_on_ipfs:
- If set to True, the asset metadata will contain the IPFS identifier of the
image_url
stored on IPFS. For more information, refer to the section metadata and storage.- If set to False, the asset metadata will contain the
image_url
meaning that you are expected to ensure the file hosting.
Important about IPFS storage
When using our API to create an asset, we will store the asset's image and metadata on IPFS only for apps in production
Asset's images and metadata created for apps in Development will be hosted in our storage and not on IPFS.
Request example
Sample: request body
{
"user_uid": "324167489835",
"asset_external_id": "asset_external_id_1",
"collection_uid": "221137489875",
"data": {
"name": "Dave Starbelly",
"unique_name": true,
"image_url": "https://storage.googleapis.com/opensea-prod.appspot.com/puffs/3.png",
"store_image_on_ipfs": true,
"description": "Friendly OpenSea Creature that enjoys long swims in the ocean.",
"external_url": "https://openseacreatures.io/3",
"attributes": [
{
"trait_type": "Base",
"value": "Starfish"
},
{
"trait_type": "Eyes",
"value": "Big"
},
{
"trait_type": "Aqua Power",
"display_type": "boost_number",
"value": 40
},
{
"trait_type": "Stamina Increase",
"display_type": "boost_percentage",
"value": 10
},
]
}
}
Response
Response example
Sample: 201 Created Response
You will receive a uid
which refers to the asset's uid:
{
"success": true,
"data": {
"uid": "122163488839", // (asset uid)
}
}
You can use this uid
to call and reference the other Asset endpoints. For example, GET /asset/{uid}
with this uid
will return the asset details.
Note:
In most cases, the asset status in the response will be
“Not minted”
due to the asynchronous operation of creating the asset on the blockchain.Once the asset is minted on the blockchain, a Webhook event will be sent if it’s enabled.
This is the same uid
that will be seen on the developer console under App > Assets.
Example
The following example creates an asset for user 111111111111 and the collection 999999999999 with your asset external id is asset-id-2.
# API_KEY is your api key
# TOKEN is the access token generated with your api key secret
curl -i \
-X POST \
-d "{\"user_uid\":\"111111111111\",\"collection_uid\":\"999999999999\",\"asset_external_id\":\"asset-id-2\",\"data\":...}" \
-H "Content-Type: application/json" \
-H "X-Api-Key: API_KEY" \
-H "Authorization: Bearer TOKEN" \
"https://api.getoriginal.com/v1/asset"
Updated 7 months ago