Import a picture into the library
const url = 'https://api.pixonaut.app/v1/assets/import';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"categoryId":"cat_4f2a9c1e","name":"Summer logo","tags":["summer","logo"],"url":"https://cdn.example.com/brand/summer-logo.png"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.pixonaut.app/v1/assets/import \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "categoryId": "cat_4f2a9c1e", "name": "Summer logo", "tags": [ "summer", "logo" ], "url": "https://cdn.example.com/brand/summer-logo.png" }'Operation ID: assets.import
Saves a picture to the library in one call, from a public url this server fetches or as base64 data (up to 655360 bytes), with its name, tags and category. It is held to an upload’s limits: its type read from its bytes, its size, its pixels and the tenant’s storage quota.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
The category to put it in: its id, as list_asset_categories returns it. Left out, it is in none.
The picture’s bytes, base64, at most 655360 bytes before encoding; a larger one is sent by url. Give this or url.
The picture’s name in the library, e.g. Summer logo.
The picture’s tags: lowercase words, e.g. summer, logo. At most 100.
Where to fetch the picture: a public http(s) URL answering with the image itself. Give this or data.
Examples
Example
{ "categoryId": "cat_4f2a9c1e", "name": "Summer logo", "tags": [ "summer", "logo" ], "url": "https://cdn.example.com/brand/summer-logo.png"}Responses
Section titled “Responses”The picture is in the library
object
Examples
Example
{ "assetId": "up_7a3e9b102c4d4e5f9a6b1c2d", "categoryId": "cat_4f2a9c1e", "heightPx": 1600, "name": "Summer logo", "tags": [ "summer", "logo" ], "widthPx": 2400}Headers
Section titled “Headers”Every response names the request it answers in X-Request-Id: the id the request was sent with in that header, when it is well formed, else one the API gave it. Quote it when reporting a refusal or a failure: the API’s log lines for that request carry it.
Refused: unauthorized
object
Examples
unauthorized
{ "error": "unauthorized"}Headers
Section titled “Headers”Every response names the request it answers in X-Request-Id: the id the request was sent with in that header, when it is well formed, else one the API gave it. Quote it when reporting a refusal or a failure: the API’s log lines for that request carry it.
Refused: origin_forbidden, forbidden, feature_disabled, workspace_suspended
object
The feature the tenant does not have. Always sent with feature_disabled.
Examples
feature_disabled
{ "error": "feature_disabled", "feature": "api"}forbidden
{ "error": "forbidden"}origin_forbidden
{ "error": "origin_forbidden"}workspace_suspended
{ "error": "workspace_suspended"}Headers
Section titled “Headers”Every response names the request it answers in X-Request-Id: the id the request was sent with in that header, when it is well formed, else one the API gave it. Quote it when reporting a refusal or a failure: the API’s log lines for that request carry it.
Refused: size_mismatch, unsupported_mime, animation_not_supported, not_a_valid_image, pixel_dimensions_too_large, size_out_of_bounds, invalid_tag, unknown_category, url_refused, payload_too_large, invalid_input
object
Always sent with unsupported_mime.
Sent with payload_too_large.
Always sent with pixel_dimensions_too_large.
Sent with url_refused.
Always sent with size_out_of_bounds, payload_too_large.
Sent with pixel_dimensions_too_large.
Sent with pixel_dimensions_too_large.
Always sent with url_refused.
Always sent with invalid_tag.
Always sent with pixel_dimensions_too_large.
Examples
animation_not_supported
{ "error": "animation_not_supported"}invalid_input
{ "error": "invalid_input"}invalid_tag
{ "error": "invalid_tag", "tag": "string"}not_a_valid_image
{ "error": "not_a_valid_image"}payload_too_large
{ "error": "payload_too_large", "maxBytes": 0}pixel_dimensions_too_large
{ "error": "pixel_dimensions_too_large", "heightPx": 0, "widthPx": 0}size_mismatch
{ "error": "size_mismatch"}size_out_of_bounds
{ "error": "size_out_of_bounds", "maxBytes": 0}unknown_category
{ "error": "unknown_category"}unsupported_mime
{ "allowed": [ "string" ], "error": "unsupported_mime"}url_refused
{ "error": "url_refused", "reason": "scheme"}Headers
Section titled “Headers”Every response names the request it answers in X-Request-Id: the id the request was sent with in that header, when it is well formed, else one the API gave it. Quote it when reporting a refusal or a failure: the API’s log lines for that request carry it.
Refused: rate_limited
object
Examples
rate_limited
{ "error": "rate_limited"}Headers
Section titled “Headers”Every response names the request it answers in X-Request-Id: the id the request was sent with in that header, when it is well formed, else one the API gave it. Quote it when reporting a refusal or a failure: the API’s log lines for that request carry it.
Refused: preview_failed, import_failed, db_error. A request that failed unexpectedly answers as text instead.
object
Examples
db_error
{ "error": "db_error"}import_failed
{ "error": "import_failed"}preview_failed
{ "error": "preview_failed"}Headers
Section titled “Headers”Every response names the request it answers in X-Request-Id: the id the request was sent with in that header, when it is well formed, else one the API gave it. Quote it when reporting a refusal or a failure: the API’s log lines for that request carry it.
Refused: fetch_failed
object
Examples
fetch_failed
{ "error": "fetch_failed"}Headers
Section titled “Headers”Every response names the request it answers in X-Request-Id: the id the request was sent with in that header, when it is well formed, else one the API gave it. Quote it when reporting a refusal or a failure: the API’s log lines for that request carry it.
Refused: lock_timeout
object
Examples
lock_timeout
{ "error": "lock_timeout"}Headers
Section titled “Headers”Every response names the request it answers in X-Request-Id: the id the request was sent with in that header, when it is well formed, else one the API gave it. Quote it when reporting a refusal or a failure: the API’s log lines for that request carry it.
Refused: storage_quota_exceeded. The tenant’s storage quota would be exceeded. usedBytes and quotaBytes are left out for a publishable key.
object
Always sent with storage_quota_exceeded.
Always sent with storage_quota_exceeded.
Examples
storage_quota_exceeded
{ "error": "storage_quota_exceeded"}storage_quota_exceeded (usedBytes, quotaBytes)
{ "error": "storage_quota_exceeded", "quotaBytes": 0, "usedBytes": 0}Headers
Section titled “Headers”Every response names the request it answers in X-Request-Id: the id the request was sent with in that header, when it is well formed, else one the API gave it. Quote it when reporting a refusal or a failure: the API’s log lines for that request carry it.
Questions? Write to [email protected].