Agent output files: artifacts/download returns 401 for all API clients (OAuth and API key)

Hi awork team,

I’m building a VS Code extension that talks to custom agents via the public API (OAuth 2.0, PKCE, public client app, scopes full_access offline_access). Creating threads, sending messages, polling status, reading messages, credits, uploading temporary files: all of this works fine.

Problem: I can’t download the agent’s output files.

GET /agents/threads/{threadId}/messages returns the generated files in temporaryFiles like this:

{
  "id": "/workspace/output/.gitignore",
  "name": ".gitignore",
  "mimeType": "application/octet-stream",
  "sandboxPath": null,
  "downloadUrl": "/agents/threads/{threadId}/artifacts/download?path=%2Fworkspace%2Foutput%2F.gitignore"
}

The id is a sandbox path, not a file ID, so the documented routes /agents/threads/{threadId}/files/{fileId}/download and /temporaryfiles/{fileId}/download can’t be used.

The downloadUrl route fails with the OAuth token, no matter how the path is written (/workspace/output/x, x, output/x):

401 {"code":"unauthorized","description":"No permissions to access this endpoint."}

An API key gives the same result: GET /agents returns 200 with the key, but artifacts/download returns the same 401 („No permissions to access this endpoint.“).

The same route works in the awork web app (200, file content). The browser sends no Authorization header there, only the session cookie. So the endpoint seems to accept only the web session and is blocked for all API clients (OAuth and API key).

Questions

  1. Is artifacts/download meant to be used by API clients? If so, which permission or client setting is needed?
  2. If not: is there another supported way for an integration to get the files an agent saved in its output folder (for example a real file ID in temporaryFiles, or a documented download route)?
  3. Related: the web app lists chats via GET /agents/threads?filterby=... (own and shared threads). Is this endpoint supported for client apps? The docs only list /agents/management/threads.

I can share thread IDs privately if that helps.

Thanks, Martin.

Hi Martin,

I opened a change request internally to make the endpoints public and let you know when it’s released, should not take long.

And cool that you build on top of our agents :heart:

Hi @MartinR ,

thanks for the detailed report, that helped a lot. Downloading agent output files was not released for API clients yet. The endpoint was still internal, so only our own apps could call it, and OAuth and API key clients got the 401. We released it for API clients today and it’s live now. Can you try again?

To your questions:

  1. Yes, artifacts/download now works for API clients. You don’t need a special permission or client setting. The downloadUrl from temporaryFiles works with your OAuth token or API key, as long as the user can read the thread. The URL is relative to https://api.awork.com/api/v1.
  2. For agent output files, the id in temporaryFiles is the sandbox path, not a file ID. So /temporaryfiles/{fileId}/download and /agents/threads/{threadId}/files/{fileId}/download don’t work for them. Those two are only for uploaded files. Please use downloadUrl. We also updated the docs there.
  3. GET /agents/threads is internal at the moment and not released for client apps. /agents/management/threads is only for admins and usage analytics. For now, please keep the thread IDs you create in your extension. A public list endpoint is a good point, I’ll take it to the team.

Hi Nils,

I can confirm, downloads are working now. It makes thinks significant easier! I highly appreachiate this change in your API and how quick it was implemented.
Thank you!
Martin

Btw: this is the vscode extension, if anybody is interessted (directed by me, coded by AI, still testing and evolving): GitHub - mrtnRitter/Monarch · GitHub