error using /files/v3/files/import-from-url/async API

Hi,

I’m trying to use the API to updload file form url in Hubspot

Using Zapier or Postman I always get the same résult :

{

"id": "AAAAFy1nmLQ",

"links": {

    "status": "https://api-na1.hubspot.com/files/v3/files/import-from-url/async/tasks/AAAAFy1nmLQ/status"

}

}

And the status url returns :

{"status":"error","message":"Csrf token is missing from the request.","correlationId":"82b220b4-1179-4a9e-83a3-d1c51fd23c91","engagement":{"hapikey":"Not engaged, auth is missing","service-to-service":"service-to-service not engaged. Metadata for service-to-service request not found.","oauth-token":"Not engaged, auth is missing","app-cookie":"Engaged","internal-cookie":"internal-cookie not engaged. Cookie not found in the request."}}

I don’t even know what a Csrf token is and surely not how to send that token in my request :slightly_smiling_face:

Help welcomed

Hi, @Fredito :waving_hand: One question to help give the community more detail — where is the file hosted? It is in a Google Sheet? Or hosted at a URL on your site?

Thanks! — Jaycee

Thx Jaycee,

For the begining I try with differents files available on the web (pdf).

The error is always the same where ever the file is hosted

@Jaycee_Lewis

Hi,

I’m still encounting some issues whith files files API

cf : https://community.hubspot.com/t5/APIs-Integrations/files-v3-files-error-400/td-p/748223

Any help would be appreciate

I was able to solve the issue here. The status url that they are using will not work and is incorrect.
When the response is sent back to you after the initial post

{
 "id": "AAAALEeDY4c",
 "links": {
 "status": "https://api-na1.hubspot.com/files/v3/files/import-from-url/async/tasks/AAAALEeDY4c/status"
 }
}

This url: https://api-na1.hubspot.com/files/v3/files/import-from-url/async/tasks/AAAALEeDY4c/status Is not somethign you can access -- this is a url that seems to be locked by HubSpot Employees (or some sort of access level) or something similar.
Based upon the documentation, you need to query

https://api.hubapi.com/files/v3/files/import-from-url/async/tasks/{taskId}/status

So you would use the ID from the initial response as the taskId, and the Get request shoudl show you an actual status like:

{
 "status": "COMPLETE",
 "result": {
 "id": "190181141614",
 "createdAt": "2025-05-15T12:09:59.063Z",
 "updatedAt": "2025-05-15T12:09:59.063Z",
 "parentFolderId": "190180156072",
 "name": "13.0_sharp-1",
 "path": "/test-curl-upload-async/13.0_sharp-1.svg",
 "size": 7886,
 "height": 858,
 "width": 858,
 "encoding": "svg",
 "type": "IMG",
 "extension": "svg",
 "defaultHostingUrl": "https://21077404.fs1.hubspotusercontent-na1.net/hubfs/21077404/test-curl-upload-async/13.0_sharp-1.svg",
 "url": "https://21077404.fs1.hubspotusercontent-na1.net/hubfs/21077404/test-curl-upload-async/13.0_sharp-1.svg",
 "isUsableInContent": true,
 "access": "PUBLIC_INDEXABLE",
 "fileMd5": "0bc73a48ba08a825ffda5058eef92fd9",
 "sourceGroup": "CONTENT",
 "archived": false
 },
 "startedAt": "2025-05-15T12:09:58.825Z",
 "completedAt": "2025-05-15T12:09:59.063Z",
 "taskId": "AAAALEet7G4"
}