Hi Prismic Support,
I am attempting to upload images to the Media Library via the Asset API (https://asset-api.prismic.io/assets) using a Node.js script. Despite following the documentation, I am consistently receiving a 401 Unauthorized error with the body: {"error":"invalid_token"}.
Here is my setup:
-
Endpoint:
POST https://asset-api.prismic.io/assets -
Headers:
-
Authorization: Bearer [MY_TOKEN] -
repository: [MY_REPO_NAME]
-
-
Body:
multipart/form-datacontaining the file and metadata. -
Token Source: I have tried using the Permanent Access Token generated under API and Security > Content API.
My Questions:
-
Which token is required for the Asset API? Should I use the "Permanent Access Token" from Content API, or the "Write API Token" found under API > Write APIs > Tokens?
-
Endpoint Authentication: Is the
repositoryheader mandatory when using the globalasset-api.prismic.ioURL, or should I be using a repository-specific URL?
Any clarification on the correct authentication flow for the Asset API in a Node.js environment would be greatly appreciated.