6

I'm using the Notion API Beta, reading pages from a table that has a "Files & media" property I'm interested in. The API response just gives me the names of the files uploaded there, but I don't have a URL to actually access them. What am I missing? Thanks.

{
  "Photo": {
    "id": "xxxx",
    "type": "files",
    "files": [
      {
        "name": "000150748673-ofnuhb-t500x500.jpg"
      }
    ]
  }
}

Update: see answer.


lorenzo-s
  • 16,603
  • 15
  • 54
  • 86
  • Do they expect you to prepend your workspace URL? I don’t know how to get it programmatically but you could probably hardcode a string for testing. – prieber May 15 '21 at 23:07
  • @prieber Where did you get that info? It looks it's not working, it says `{ "message": "File not found" }` – lorenzo-s May 15 '21 at 23:14
  • Oh I just made that up, I haven’t used the API yet but thought that might be a good place to start. – prieber May 15 '21 at 23:16
  • 1
    You can't at the moment. The URL of the uploaded files is presigned when you try to download them. You'll notice they point to a URL that has secure.notion-static.com inside it. – Quan You May 20 '21 at 17:58

2 Answers2

5

The Notion API currently does not support file uploads or downloads (Notion-Version: 2021-05-13). It does not return a URL to the stored file.

adlopez15
  • 3,449
  • 2
  • 14
  • 19
4

The API has been updated and it now provides a temporary authenticated URL to files uploaded in Notion. For example:

{
  "Photo": {
    "id": "xxxx",
    "type": "files",
    "files": [
      {
        "name": "000150748673-ofnuhb-t500x500.jpg",
        "type": "file",
        "file": {
          "url": "https://s3.us-west-2.amazonaws.com/...",
          "expiry_time": "2021-09-22T09:00:56.029Z"
        }
      }
    ]
  }
}
lorenzo-s
  • 16,603
  • 15
  • 54
  • 86