archastro.platform.v1.resources.files
1# Copyright (c) 2026 ArchAstro Inc. Licensed under the MIT License. 2# This file is auto-generated by @archastro/sdk-generator. Do not edit. 3# Content hash: eefe9c7e925d 4 5from __future__ import annotations 6 7from typing import Any, Required, TypedDict 8 9from ...runtime.http_client import HttpClient, SyncHttpClient 10from ...types.common import StorageFile 11 12 13class FileCreateInputAclAddItem(TypedDict, total=False): 14 actions: Required[list[str]] 15 'Array of action strings the principal is permitted to perform, e.g. `["read", "write"]`. Must contain at least one entry.' 16 principal: str | None 17 'The identifier of the principal. A string ID for `"user"`, `"team"`, `"org"`, and `"agent"` types; one of `"admin"`, `"member"`, or `"viewer"` for `"org_role"`; omit entirely when `principal_type` is `"everyone"`.' 18 principal_type: Required[str] 19 'The kind of principal receiving the grant. One of `"user"`, `"team"`, `"org"`, `"org_role"`, `"agent"`, or `"everyone"`.' 20 21 22class FileCreateInputAclGrantsItem(TypedDict, total=False): 23 actions: Required[list[str]] 24 'Array of action strings the principal is permitted to perform, e.g. `["read", "write"]`. Must contain at least one entry.' 25 principal: str | None 26 'The identifier of the principal. A string ID for `"user"`, `"team"`, `"org"`, and `"agent"` types; one of `"admin"`, `"member"`, or `"viewer"` for `"org_role"`; omit entirely when `principal_type` is `"everyone"`.' 27 principal_type: Required[str] 28 'The kind of principal receiving the grant. One of `"user"`, `"team"`, `"org"`, `"org_role"`, `"agent"`, or `"everyone"`.' 29 30 31class FileCreateInputAclRemoveItem(TypedDict, total=False): 32 principal: str | None 33 'The identifier of the principal to remove. A string ID for `"user"`, `"team"`, `"org"`, and `"agent"` types; one of `"admin"`, `"member"`, or `"viewer"` for `"org_role"`. Omit when `principal_type` is `"everyone"`.' 34 principal_type: Required[str] 35 'The kind of principal to remove. One of `"user"`, `"team"`, `"org"`, `"org_role"`, `"agent"`, or `"everyone"`.' 36 37 38class FileCreateInputAcl(TypedDict, total=False): 39 add: list[FileCreateInputAclAddItem] | None 40 "Patch mode: grants to add or merge into the existing list. Cannot be combined with `grants`." 41 grants: list[FileCreateInputAclGrantsItem] | None 42 "Replace mode: the complete new list of grants that replaces all existing entries. Send an empty array (`[]`) to clear all grants. Cannot be combined with `add` or `remove`." 43 remove: list[FileCreateInputAclRemoveItem] | None 44 "Patch mode: principals whose grants should be removed from the existing list. Cannot be combined with `grants`." 45 46 47class FileCreateInput(TypedDict, total=False): 48 "Upload a file" 49 50 acl: FileCreateInputAcl | None 51 "Access control list for the file. Supports explicit `read` and `write` grants to users, teams, organizations, organization roles, agents, or everyone." 52 agent: str | None 53 "Agent ID (`agi_...`) to associate with this file. When provided, the file's organization is derived from the agent." 54 content_type: Required[str] 55 'MIME type of the file, e.g. `"image/png"` or `"application/pdf"`.' 56 data: Required[str] 57 "Base64-encoded binary content of the file to upload." 58 filename: Required[str] 59 'Original filename including extension, e.g. `"avatar.png"`.' 60 org: str | None 61 "Organization ID (`org_...`) to associate with this file. Optional; defaults to the viewer's organization when omitted." 62 share: bool | None 63 "When `true`, marks the file publicly shareable and returns a stable, non-expiring `share_url` fetchable without authentication. Only image content types can be shared." 64 team: str | None 65 "Team ID (`tem_...`) that owns this file. Takes precedence over `user` when both are provided." 66 user: str | None 67 "User ID (`usr_...`) that owns this file. Defaults to the authenticated user when neither `user` nor `team` is specified." 68 69 70class FileUpdateInput(TypedDict, total=False): 71 "Update a file" 72 73 filename: str | None 74 'New name for the file, including extension, e.g. `"report_v2.pdf"`. Omit to leave the current filename unchanged.' 75 provider_metadata: dict[str, Any] | None 76 "Arbitrary key-value map of provider-specific metadata to store alongside the file. Replaces the entire existing `provider_metadata` map. Omit to leave it unchanged." 77 share: bool | None 78 "Set `true` to mark the file publicly shareable via its stable `share_url` (image content types only), or `false` to revoke public sharing. Re-enabling sharing reactivates any previously issued share URLs for the file. Omit to leave sharing unchanged." 79 80 81class AsyncFileResource: 82 def __init__(self, http: HttpClient): 83 self._http = http 84 85 async def create(self, input: FileCreateInput) -> StorageFile: 86 """ 87 Upload a file 88 Creates a new file from base64-encoded content and returns the resulting file object, 89 including a signed download URL. Use this endpoint to store images, documents, or 90 other binary assets that can then be referenced by agents, teams, or users. 91 The JSON body uses Platform's default 8,000,000-byte parser budget; the 92 an upstream proxy in front of Platform may have a separate 32 MiB request cap. Base64 requires 93 `4 * ceil(binary_bytes / 3)` bytes, plus the UTF-8 JSON envelope (including 94 filename, owner IDs, escaping and other fields). For an envelope of E bytes, 95 budget at most `3 * floor((8,000,000 - E) / 4)` binary bytes: less than 96 6,000,000 bytes (about 5.72 MiB). Do not rely on parser chunk overshoot. 97 Oversized JSON requests are rejected with HTTP 413 before upload processing. 98 App scope is derived from the authenticated viewer's bearer token or publishable key. 99 You may optionally associate the file with an organization, team, user, or agent by 100 passing the corresponding ID. If no owner is specified and the viewer is a user, the 101 file is automatically attributed to that user. 102 Pass `share: true` to additionally mint a stable public URL for the file 103 (returned as `share_url`), fetchable by anyone without authentication for 104 example to embed an uploaded image in a GitHub PR body or other external 105 markdown. The URL does not expire. Sharing is revoked by setting 106 `share: false` on `PATCH /api/v1/files/:file` with the same credential 107 (or `archastro update file <id> --unshare`); re-enabling sharing 108 reactivates previously issued URLs. Only image content types can be 109 shared. 110 Returns `422` when the `data` field is not valid base64, the changeset is 111 invalid, or `share` is requested for a non-image content type. 112 Returns `403` when the request lacks the required app scope. 113 114 Args: 115 input: Request body. 116 input.acl: Access control list for the file. Supports explicit `read` and `write` grants to users, teams, organizations, organization roles, agents, or everyone. 117 input.agent: Agent ID (`agi_...`) to associate with this file. When provided, the file's organization is derived from the agent. 118 input.content_type: MIME type of the file, e.g. `"image/png"` or `"application/pdf"`. 119 input.data: Base64-encoded binary content of the file to upload. 120 input.filename: Original filename including extension, e.g. `"avatar.png"`. 121 input.org: Organization ID (`org_...`) to associate with this file. Optional; defaults to the viewer's organization when omitted. 122 input.share: When `true`, marks the file publicly shareable and returns a stable, non-expiring `share_url` fetchable without authentication. Only image content types can be shared. 123 input.team: Team ID (`tem_...`) that owns this file. Takes precedence over `user` when both are provided. 124 input.user: User ID (`usr_...`) that owns this file. Defaults to the authenticated user when neither `user` nor `team` is specified. 125 126 Returns: 127 The newly created file, including a signed download URL. 128 """ 129 return await self._http.request( 130 "/api/v1/files", 131 method="POST", 132 body=input, 133 response_type=StorageFile, 134 ) 135 136 async def update(self, file: str, input: FileUpdateInput) -> StorageFile: 137 """ 138 Update a file 139 Updates mutable fields of an existing file. Only the fields you supply are 140 changed; omitted fields retain their current values. The file's stored content 141 and `content_type` cannot be changed after creation. 142 This endpoint is the companion to `share: true` on file upload: the same 143 credential that granted public sharing can revoke it here with `share: false` 144 (or grant it later with `share: true`; only image content types can be 145 shared, and re-enabling sharing reactivates any previously issued share 146 URLs). App scope is derived from the authenticated viewer, matching upload. 147 A file that exists but is not visible to the current viewer returns `404` 148 rather than `403` to avoid revealing the file's existence. 149 150 Args: 151 file: File ID (`fil_...`) of the file to update. 152 input: Request body. 153 input.filename: New name for the file, including extension, e.g. `"report_v2.pdf"`. Omit to leave the current filename unchanged. 154 input.provider_metadata: Arbitrary key-value map of provider-specific metadata to store alongside the file. Replaces the entire existing `provider_metadata` map. Omit to leave it unchanged. 155 input.share: Set `true` to mark the file publicly shareable via its stable `share_url` (image content types only), or `false` to revoke public sharing. Re-enabling sharing reactivates any previously issued share URLs for the file. Omit to leave sharing unchanged. 156 157 Returns: 158 The updated file, including a signed download URL. 159 """ 160 return await self._http.request( 161 f"/api/v1/files/{file}", 162 method="PATCH", 163 body=input, 164 response_type=StorageFile, 165 ) 166 167 async def avatar(self, file: str, token: str) -> dict[str, str]: 168 """ 169 Fetch an agent or user avatar image 170 Returns the raw image bytes for an agent's or user's profile picture identified 171 by `file`. Chat messages and integration partners (such as Slack) fetch avatars 172 through it with plain GET requests, without bearer tokens. Authorization is 173 performed via a short, stable capability `token` rather than an HTTP header. 174 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 175 but it is invalidated when the profile picture is replaced or its agent or user 176 is deleted shared caches may continue serving the old image until the 177 `Cache-Control` max-age of one hour elapses. The endpoint never redirects to 178 a signed storage URL; bytes are served inline so behavior is consistent across 179 storage backends. 180 All failure modes invalid file ID, invalid token, file not currently referenced 181 as an agent avatar return a uniform `404` to avoid acting as an existence oracle. 182 183 Args: 184 file: File ID of the profile picture (`fil_...`). Must be currently set as an agent's or user's profile picture within the same app. 185 token: HMAC capability token authorizing access to this specific file. Obtained from the avatar URL minted when the profile picture was set. 186 187 Returns: 188 Raw image bytes of the avatar, served with the file's original content type. 189 """ 190 query: dict[str, object] = {} 191 query["token"] = token 192 return await self._http.request_raw(f"/api/v1/files/{file}/avatar", query=query) 193 194 async def download(self, file: str) -> dict[str, str]: 195 """ 196 Download a file's bytes 197 Returns the raw binary content of a file the authenticated viewer may see. 198 The response `Content-Type` header reflects the file's stored MIME type and 199 `Content-Disposition` names the file as an attachment, so a browser can hand 200 the body to the download manager directly. 201 Unlike `Show` (which mints a storage URL the browser must resolve itself), 202 this endpoint serves bytes inline through the authenticated API mount, so it 203 behaves identically across storage backends: local files are not exposed as 204 unauthenticated static paths, and signed GCS URLs never cross the browser 205 boundary. A file that exists but is not visible to the current viewer 206 returns `404` rather than `403` to avoid revealing the file's existence. 207 Byte downloads are limited to 32 MiB (33,554,432 bytes). The storage provider 208 enforces this limit on actual content, independently of stored size metadata. 209 Larger content returns HTTP `413` with error code `content_too_large`. 210 211 Args: 212 file: File ID (`fil_...`) of the file to download. 213 214 Returns: 215 Raw binary content of the file, served with the file's stored MIME type. 216 """ 217 return await self._http.request_raw(f"/api/v1/files/{file}/download") 218 219 async def org_logo(self, file: str, token: str) -> dict[str, str]: 220 """ 221 Fetch an org logo image 222 Returns the raw image bytes for an organization's logo identified by `file`. 223 This endpoint backs the `org_logo.url` field of catalog payloads (such as 224 `GET /api/v1/solutions`), which anonymous consumers the public marketplace's 225 page cache, OpenGraph scrapers may hold far longer than a signed storage URL 226 lives. Authorization is performed via a short, stable capability `token` rather 227 than an HTTP header, so the URL never expires. 228 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 229 but it is invalidated when the org's logo is replaced or removed shared caches 230 may continue serving the old image until the `Cache-Control` max-age of one hour 231 elapses. The endpoint never redirects to a signed storage URL; bytes are served 232 inline so behavior is consistent across storage backends. 233 All failure modes invalid file ID, invalid token, file not currently referenced 234 as an org logo return a uniform `404` to avoid acting as an existence oracle. 235 236 Args: 237 file: File ID of the org's logo (`fil_...`). Must be currently set as an organization's logo within the same app. 238 token: HMAC capability token authorizing access to this specific file. Obtained from the `org_logo.url` minted when the logo was serialized. 239 240 Returns: 241 Raw image bytes of the org logo, served with the file's original content type. 242 """ 243 query: dict[str, object] = {} 244 query["token"] = token 245 return await self._http.request_raw(f"/api/v1/files/{file}/org_logo", query=query) 246 247 async def share(self, file: str, token: str) -> dict[str, str]: 248 """ 249 Fetch a publicly shared file 250 Returns the raw image bytes for a file that was explicitly shared for public 251 access, identified by `file`. This endpoint is designed for consumers that hold 252 a URL far longer than a signed storage URL lives GitHub PR bodies (whose camo 253 image proxy re-fetches from the origin URL), wikis, and issue trackers and 254 fetch it via plain GET requests without bearer token support. Authorization is 255 performed via a short, stable capability `token` rather than an HTTP header. 256 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 257 but it is invalidated when sharing is turned off for the file (`share: false` on 258 the file update endpoint) or the file is deleted shared caches may continue 259 serving the bytes until the `Cache-Control` max-age of one hour elapses. The 260 endpoint never redirects to a signed storage URL; bytes are served inline so 261 behavior is consistent across storage backends. Only image content types are 262 served. 263 All failure modes invalid file ID, invalid token, file not currently shared 264 return a uniform `404` to avoid acting as an existence oracle. 265 266 Args: 267 file: File ID of the shared file (`fil_...`). The file must currently be marked as publicly shared. 268 token: HMAC capability token authorizing access to this specific file. Obtained from the `share_url` returned when the file was uploaded with `share: true`. 269 270 Returns: 271 Raw image bytes of the shared file, served with the file's original content type. 272 """ 273 query: dict[str, object] = {} 274 query["token"] = token 275 return await self._http.request_raw(f"/api/v1/files/{file}/share", query=query) 276 277 278class FileResource: 279 def __init__(self, http: SyncHttpClient): 280 self._http = http 281 282 def create(self, input: FileCreateInput) -> StorageFile: 283 """ 284 Upload a file 285 Creates a new file from base64-encoded content and returns the resulting file object, 286 including a signed download URL. Use this endpoint to store images, documents, or 287 other binary assets that can then be referenced by agents, teams, or users. 288 The JSON body uses Platform's default 8,000,000-byte parser budget; the 289 an upstream proxy in front of Platform may have a separate 32 MiB request cap. Base64 requires 290 `4 * ceil(binary_bytes / 3)` bytes, plus the UTF-8 JSON envelope (including 291 filename, owner IDs, escaping and other fields). For an envelope of E bytes, 292 budget at most `3 * floor((8,000,000 - E) / 4)` binary bytes: less than 293 6,000,000 bytes (about 5.72 MiB). Do not rely on parser chunk overshoot. 294 Oversized JSON requests are rejected with HTTP 413 before upload processing. 295 App scope is derived from the authenticated viewer's bearer token or publishable key. 296 You may optionally associate the file with an organization, team, user, or agent by 297 passing the corresponding ID. If no owner is specified and the viewer is a user, the 298 file is automatically attributed to that user. 299 Pass `share: true` to additionally mint a stable public URL for the file 300 (returned as `share_url`), fetchable by anyone without authentication for 301 example to embed an uploaded image in a GitHub PR body or other external 302 markdown. The URL does not expire. Sharing is revoked by setting 303 `share: false` on `PATCH /api/v1/files/:file` with the same credential 304 (or `archastro update file <id> --unshare`); re-enabling sharing 305 reactivates previously issued URLs. Only image content types can be 306 shared. 307 Returns `422` when the `data` field is not valid base64, the changeset is 308 invalid, or `share` is requested for a non-image content type. 309 Returns `403` when the request lacks the required app scope. 310 311 Args: 312 input: Request body. 313 input.acl: Access control list for the file. Supports explicit `read` and `write` grants to users, teams, organizations, organization roles, agents, or everyone. 314 input.agent: Agent ID (`agi_...`) to associate with this file. When provided, the file's organization is derived from the agent. 315 input.content_type: MIME type of the file, e.g. `"image/png"` or `"application/pdf"`. 316 input.data: Base64-encoded binary content of the file to upload. 317 input.filename: Original filename including extension, e.g. `"avatar.png"`. 318 input.org: Organization ID (`org_...`) to associate with this file. Optional; defaults to the viewer's organization when omitted. 319 input.share: When `true`, marks the file publicly shareable and returns a stable, non-expiring `share_url` fetchable without authentication. Only image content types can be shared. 320 input.team: Team ID (`tem_...`) that owns this file. Takes precedence over `user` when both are provided. 321 input.user: User ID (`usr_...`) that owns this file. Defaults to the authenticated user when neither `user` nor `team` is specified. 322 323 Returns: 324 The newly created file, including a signed download URL. 325 """ 326 return self._http.request( 327 "/api/v1/files", 328 method="POST", 329 body=input, 330 response_type=StorageFile, 331 ) 332 333 def update(self, file: str, input: FileUpdateInput) -> StorageFile: 334 """ 335 Update a file 336 Updates mutable fields of an existing file. Only the fields you supply are 337 changed; omitted fields retain their current values. The file's stored content 338 and `content_type` cannot be changed after creation. 339 This endpoint is the companion to `share: true` on file upload: the same 340 credential that granted public sharing can revoke it here with `share: false` 341 (or grant it later with `share: true`; only image content types can be 342 shared, and re-enabling sharing reactivates any previously issued share 343 URLs). App scope is derived from the authenticated viewer, matching upload. 344 A file that exists but is not visible to the current viewer returns `404` 345 rather than `403` to avoid revealing the file's existence. 346 347 Args: 348 file: File ID (`fil_...`) of the file to update. 349 input: Request body. 350 input.filename: New name for the file, including extension, e.g. `"report_v2.pdf"`. Omit to leave the current filename unchanged. 351 input.provider_metadata: Arbitrary key-value map of provider-specific metadata to store alongside the file. Replaces the entire existing `provider_metadata` map. Omit to leave it unchanged. 352 input.share: Set `true` to mark the file publicly shareable via its stable `share_url` (image content types only), or `false` to revoke public sharing. Re-enabling sharing reactivates any previously issued share URLs for the file. Omit to leave sharing unchanged. 353 354 Returns: 355 The updated file, including a signed download URL. 356 """ 357 return self._http.request( 358 f"/api/v1/files/{file}", 359 method="PATCH", 360 body=input, 361 response_type=StorageFile, 362 ) 363 364 def avatar(self, file: str, token: str) -> dict[str, str]: 365 """ 366 Fetch an agent or user avatar image 367 Returns the raw image bytes for an agent's or user's profile picture identified 368 by `file`. Chat messages and integration partners (such as Slack) fetch avatars 369 through it with plain GET requests, without bearer tokens. Authorization is 370 performed via a short, stable capability `token` rather than an HTTP header. 371 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 372 but it is invalidated when the profile picture is replaced or its agent or user 373 is deleted shared caches may continue serving the old image until the 374 `Cache-Control` max-age of one hour elapses. The endpoint never redirects to 375 a signed storage URL; bytes are served inline so behavior is consistent across 376 storage backends. 377 All failure modes invalid file ID, invalid token, file not currently referenced 378 as an agent avatar return a uniform `404` to avoid acting as an existence oracle. 379 380 Args: 381 file: File ID of the profile picture (`fil_...`). Must be currently set as an agent's or user's profile picture within the same app. 382 token: HMAC capability token authorizing access to this specific file. Obtained from the avatar URL minted when the profile picture was set. 383 384 Returns: 385 Raw image bytes of the avatar, served with the file's original content type. 386 """ 387 query: dict[str, object] = {} 388 query["token"] = token 389 return self._http.request_raw(f"/api/v1/files/{file}/avatar", query=query) 390 391 def download(self, file: str) -> dict[str, str]: 392 """ 393 Download a file's bytes 394 Returns the raw binary content of a file the authenticated viewer may see. 395 The response `Content-Type` header reflects the file's stored MIME type and 396 `Content-Disposition` names the file as an attachment, so a browser can hand 397 the body to the download manager directly. 398 Unlike `Show` (which mints a storage URL the browser must resolve itself), 399 this endpoint serves bytes inline through the authenticated API mount, so it 400 behaves identically across storage backends: local files are not exposed as 401 unauthenticated static paths, and signed GCS URLs never cross the browser 402 boundary. A file that exists but is not visible to the current viewer 403 returns `404` rather than `403` to avoid revealing the file's existence. 404 Byte downloads are limited to 32 MiB (33,554,432 bytes). The storage provider 405 enforces this limit on actual content, independently of stored size metadata. 406 Larger content returns HTTP `413` with error code `content_too_large`. 407 408 Args: 409 file: File ID (`fil_...`) of the file to download. 410 411 Returns: 412 Raw binary content of the file, served with the file's stored MIME type. 413 """ 414 return self._http.request_raw(f"/api/v1/files/{file}/download") 415 416 def org_logo(self, file: str, token: str) -> dict[str, str]: 417 """ 418 Fetch an org logo image 419 Returns the raw image bytes for an organization's logo identified by `file`. 420 This endpoint backs the `org_logo.url` field of catalog payloads (such as 421 `GET /api/v1/solutions`), which anonymous consumers the public marketplace's 422 page cache, OpenGraph scrapers may hold far longer than a signed storage URL 423 lives. Authorization is performed via a short, stable capability `token` rather 424 than an HTTP header, so the URL never expires. 425 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 426 but it is invalidated when the org's logo is replaced or removed shared caches 427 may continue serving the old image until the `Cache-Control` max-age of one hour 428 elapses. The endpoint never redirects to a signed storage URL; bytes are served 429 inline so behavior is consistent across storage backends. 430 All failure modes invalid file ID, invalid token, file not currently referenced 431 as an org logo return a uniform `404` to avoid acting as an existence oracle. 432 433 Args: 434 file: File ID of the org's logo (`fil_...`). Must be currently set as an organization's logo within the same app. 435 token: HMAC capability token authorizing access to this specific file. Obtained from the `org_logo.url` minted when the logo was serialized. 436 437 Returns: 438 Raw image bytes of the org logo, served with the file's original content type. 439 """ 440 query: dict[str, object] = {} 441 query["token"] = token 442 return self._http.request_raw(f"/api/v1/files/{file}/org_logo", query=query) 443 444 def share(self, file: str, token: str) -> dict[str, str]: 445 """ 446 Fetch a publicly shared file 447 Returns the raw image bytes for a file that was explicitly shared for public 448 access, identified by `file`. This endpoint is designed for consumers that hold 449 a URL far longer than a signed storage URL lives GitHub PR bodies (whose camo 450 image proxy re-fetches from the origin URL), wikis, and issue trackers and 451 fetch it via plain GET requests without bearer token support. Authorization is 452 performed via a short, stable capability `token` rather than an HTTP header. 453 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 454 but it is invalidated when sharing is turned off for the file (`share: false` on 455 the file update endpoint) or the file is deleted shared caches may continue 456 serving the bytes until the `Cache-Control` max-age of one hour elapses. The 457 endpoint never redirects to a signed storage URL; bytes are served inline so 458 behavior is consistent across storage backends. Only image content types are 459 served. 460 All failure modes invalid file ID, invalid token, file not currently shared 461 return a uniform `404` to avoid acting as an existence oracle. 462 463 Args: 464 file: File ID of the shared file (`fil_...`). The file must currently be marked as publicly shared. 465 token: HMAC capability token authorizing access to this specific file. Obtained from the `share_url` returned when the file was uploaded with `share: true`. 466 467 Returns: 468 Raw image bytes of the shared file, served with the file's original content type. 469 """ 470 query: dict[str, object] = {} 471 query["token"] = token 472 return self._http.request_raw(f"/api/v1/files/{file}/share", query=query)
14class FileCreateInputAclAddItem(TypedDict, total=False): 15 actions: Required[list[str]] 16 'Array of action strings the principal is permitted to perform, e.g. `["read", "write"]`. Must contain at least one entry.' 17 principal: str | None 18 'The identifier of the principal. A string ID for `"user"`, `"team"`, `"org"`, and `"agent"` types; one of `"admin"`, `"member"`, or `"viewer"` for `"org_role"`; omit entirely when `principal_type` is `"everyone"`.' 19 principal_type: Required[str] 20 'The kind of principal receiving the grant. One of `"user"`, `"team"`, `"org"`, `"org_role"`, `"agent"`, or `"everyone"`.'
Array of action strings the principal is permitted to perform, e.g. ["read", "write"]. Must contain at least one entry.
The identifier of the principal. A string ID for "user", "team", "org", and "agent" types; one of "admin", "member", or "viewer" for "org_role"; omit entirely when principal_type is "everyone".
23class FileCreateInputAclGrantsItem(TypedDict, total=False): 24 actions: Required[list[str]] 25 'Array of action strings the principal is permitted to perform, e.g. `["read", "write"]`. Must contain at least one entry.' 26 principal: str | None 27 'The identifier of the principal. A string ID for `"user"`, `"team"`, `"org"`, and `"agent"` types; one of `"admin"`, `"member"`, or `"viewer"` for `"org_role"`; omit entirely when `principal_type` is `"everyone"`.' 28 principal_type: Required[str] 29 'The kind of principal receiving the grant. One of `"user"`, `"team"`, `"org"`, `"org_role"`, `"agent"`, or `"everyone"`.'
Array of action strings the principal is permitted to perform, e.g. ["read", "write"]. Must contain at least one entry.
The identifier of the principal. A string ID for "user", "team", "org", and "agent" types; one of "admin", "member", or "viewer" for "org_role"; omit entirely when principal_type is "everyone".
32class FileCreateInputAclRemoveItem(TypedDict, total=False): 33 principal: str | None 34 'The identifier of the principal to remove. A string ID for `"user"`, `"team"`, `"org"`, and `"agent"` types; one of `"admin"`, `"member"`, or `"viewer"` for `"org_role"`. Omit when `principal_type` is `"everyone"`.' 35 principal_type: Required[str] 36 'The kind of principal to remove. One of `"user"`, `"team"`, `"org"`, `"org_role"`, `"agent"`, or `"everyone"`.'
The identifier of the principal to remove. A string ID for "user", "team", "org", and "agent" types; one of "admin", "member", or "viewer" for "org_role". Omit when principal_type is "everyone".
39class FileCreateInputAcl(TypedDict, total=False): 40 add: list[FileCreateInputAclAddItem] | None 41 "Patch mode: grants to add or merge into the existing list. Cannot be combined with `grants`." 42 grants: list[FileCreateInputAclGrantsItem] | None 43 "Replace mode: the complete new list of grants that replaces all existing entries. Send an empty array (`[]`) to clear all grants. Cannot be combined with `add` or `remove`." 44 remove: list[FileCreateInputAclRemoveItem] | None 45 "Patch mode: principals whose grants should be removed from the existing list. Cannot be combined with `grants`."
Patch mode: grants to add or merge into the existing list. Cannot be combined with grants.
Patch mode: principals whose grants should be removed from the existing list. Cannot be combined with grants.
48class FileCreateInput(TypedDict, total=False): 49 "Upload a file" 50 51 acl: FileCreateInputAcl | None 52 "Access control list for the file. Supports explicit `read` and `write` grants to users, teams, organizations, organization roles, agents, or everyone." 53 agent: str | None 54 "Agent ID (`agi_...`) to associate with this file. When provided, the file's organization is derived from the agent." 55 content_type: Required[str] 56 'MIME type of the file, e.g. `"image/png"` or `"application/pdf"`.' 57 data: Required[str] 58 "Base64-encoded binary content of the file to upload." 59 filename: Required[str] 60 'Original filename including extension, e.g. `"avatar.png"`.' 61 org: str | None 62 "Organization ID (`org_...`) to associate with this file. Optional; defaults to the viewer's organization when omitted." 63 share: bool | None 64 "When `true`, marks the file publicly shareable and returns a stable, non-expiring `share_url` fetchable without authentication. Only image content types can be shared." 65 team: str | None 66 "Team ID (`tem_...`) that owns this file. Takes precedence over `user` when both are provided." 67 user: str | None 68 "User ID (`usr_...`) that owns this file. Defaults to the authenticated user when neither `user` nor `team` is specified."
Upload a file
Access control list for the file. Supports explicit read and write grants to users, teams, organizations, organization roles, agents, or everyone.
Agent ID (agi_...) to associate with this file. When provided, the file's organization is derived from the agent.
Organization ID (org_...) to associate with this file. Optional; defaults to the viewer's organization when omitted.
Team ID (tem_...) that owns this file. Takes precedence over user when both are provided.
71class FileUpdateInput(TypedDict, total=False): 72 "Update a file" 73 74 filename: str | None 75 'New name for the file, including extension, e.g. `"report_v2.pdf"`. Omit to leave the current filename unchanged.' 76 provider_metadata: dict[str, Any] | None 77 "Arbitrary key-value map of provider-specific metadata to store alongside the file. Replaces the entire existing `provider_metadata` map. Omit to leave it unchanged." 78 share: bool | None 79 "Set `true` to mark the file publicly shareable via its stable `share_url` (image content types only), or `false` to revoke public sharing. Re-enabling sharing reactivates any previously issued share URLs for the file. Omit to leave sharing unchanged."
Update a file
New name for the file, including extension, e.g. "report_v2.pdf". Omit to leave the current filename unchanged.
Arbitrary key-value map of provider-specific metadata to store alongside the file. Replaces the entire existing provider_metadata map. Omit to leave it unchanged.
82class AsyncFileResource: 83 def __init__(self, http: HttpClient): 84 self._http = http 85 86 async def create(self, input: FileCreateInput) -> StorageFile: 87 """ 88 Upload a file 89 Creates a new file from base64-encoded content and returns the resulting file object, 90 including a signed download URL. Use this endpoint to store images, documents, or 91 other binary assets that can then be referenced by agents, teams, or users. 92 The JSON body uses Platform's default 8,000,000-byte parser budget; the 93 an upstream proxy in front of Platform may have a separate 32 MiB request cap. Base64 requires 94 `4 * ceil(binary_bytes / 3)` bytes, plus the UTF-8 JSON envelope (including 95 filename, owner IDs, escaping and other fields). For an envelope of E bytes, 96 budget at most `3 * floor((8,000,000 - E) / 4)` binary bytes: less than 97 6,000,000 bytes (about 5.72 MiB). Do not rely on parser chunk overshoot. 98 Oversized JSON requests are rejected with HTTP 413 before upload processing. 99 App scope is derived from the authenticated viewer's bearer token or publishable key. 100 You may optionally associate the file with an organization, team, user, or agent by 101 passing the corresponding ID. If no owner is specified and the viewer is a user, the 102 file is automatically attributed to that user. 103 Pass `share: true` to additionally mint a stable public URL for the file 104 (returned as `share_url`), fetchable by anyone without authentication for 105 example to embed an uploaded image in a GitHub PR body or other external 106 markdown. The URL does not expire. Sharing is revoked by setting 107 `share: false` on `PATCH /api/v1/files/:file` with the same credential 108 (or `archastro update file <id> --unshare`); re-enabling sharing 109 reactivates previously issued URLs. Only image content types can be 110 shared. 111 Returns `422` when the `data` field is not valid base64, the changeset is 112 invalid, or `share` is requested for a non-image content type. 113 Returns `403` when the request lacks the required app scope. 114 115 Args: 116 input: Request body. 117 input.acl: Access control list for the file. Supports explicit `read` and `write` grants to users, teams, organizations, organization roles, agents, or everyone. 118 input.agent: Agent ID (`agi_...`) to associate with this file. When provided, the file's organization is derived from the agent. 119 input.content_type: MIME type of the file, e.g. `"image/png"` or `"application/pdf"`. 120 input.data: Base64-encoded binary content of the file to upload. 121 input.filename: Original filename including extension, e.g. `"avatar.png"`. 122 input.org: Organization ID (`org_...`) to associate with this file. Optional; defaults to the viewer's organization when omitted. 123 input.share: When `true`, marks the file publicly shareable and returns a stable, non-expiring `share_url` fetchable without authentication. Only image content types can be shared. 124 input.team: Team ID (`tem_...`) that owns this file. Takes precedence over `user` when both are provided. 125 input.user: User ID (`usr_...`) that owns this file. Defaults to the authenticated user when neither `user` nor `team` is specified. 126 127 Returns: 128 The newly created file, including a signed download URL. 129 """ 130 return await self._http.request( 131 "/api/v1/files", 132 method="POST", 133 body=input, 134 response_type=StorageFile, 135 ) 136 137 async def update(self, file: str, input: FileUpdateInput) -> StorageFile: 138 """ 139 Update a file 140 Updates mutable fields of an existing file. Only the fields you supply are 141 changed; omitted fields retain their current values. The file's stored content 142 and `content_type` cannot be changed after creation. 143 This endpoint is the companion to `share: true` on file upload: the same 144 credential that granted public sharing can revoke it here with `share: false` 145 (or grant it later with `share: true`; only image content types can be 146 shared, and re-enabling sharing reactivates any previously issued share 147 URLs). App scope is derived from the authenticated viewer, matching upload. 148 A file that exists but is not visible to the current viewer returns `404` 149 rather than `403` to avoid revealing the file's existence. 150 151 Args: 152 file: File ID (`fil_...`) of the file to update. 153 input: Request body. 154 input.filename: New name for the file, including extension, e.g. `"report_v2.pdf"`. Omit to leave the current filename unchanged. 155 input.provider_metadata: Arbitrary key-value map of provider-specific metadata to store alongside the file. Replaces the entire existing `provider_metadata` map. Omit to leave it unchanged. 156 input.share: Set `true` to mark the file publicly shareable via its stable `share_url` (image content types only), or `false` to revoke public sharing. Re-enabling sharing reactivates any previously issued share URLs for the file. Omit to leave sharing unchanged. 157 158 Returns: 159 The updated file, including a signed download URL. 160 """ 161 return await self._http.request( 162 f"/api/v1/files/{file}", 163 method="PATCH", 164 body=input, 165 response_type=StorageFile, 166 ) 167 168 async def avatar(self, file: str, token: str) -> dict[str, str]: 169 """ 170 Fetch an agent or user avatar image 171 Returns the raw image bytes for an agent's or user's profile picture identified 172 by `file`. Chat messages and integration partners (such as Slack) fetch avatars 173 through it with plain GET requests, without bearer tokens. Authorization is 174 performed via a short, stable capability `token` rather than an HTTP header. 175 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 176 but it is invalidated when the profile picture is replaced or its agent or user 177 is deleted shared caches may continue serving the old image until the 178 `Cache-Control` max-age of one hour elapses. The endpoint never redirects to 179 a signed storage URL; bytes are served inline so behavior is consistent across 180 storage backends. 181 All failure modes invalid file ID, invalid token, file not currently referenced 182 as an agent avatar return a uniform `404` to avoid acting as an existence oracle. 183 184 Args: 185 file: File ID of the profile picture (`fil_...`). Must be currently set as an agent's or user's profile picture within the same app. 186 token: HMAC capability token authorizing access to this specific file. Obtained from the avatar URL minted when the profile picture was set. 187 188 Returns: 189 Raw image bytes of the avatar, served with the file's original content type. 190 """ 191 query: dict[str, object] = {} 192 query["token"] = token 193 return await self._http.request_raw(f"/api/v1/files/{file}/avatar", query=query) 194 195 async def download(self, file: str) -> dict[str, str]: 196 """ 197 Download a file's bytes 198 Returns the raw binary content of a file the authenticated viewer may see. 199 The response `Content-Type` header reflects the file's stored MIME type and 200 `Content-Disposition` names the file as an attachment, so a browser can hand 201 the body to the download manager directly. 202 Unlike `Show` (which mints a storage URL the browser must resolve itself), 203 this endpoint serves bytes inline through the authenticated API mount, so it 204 behaves identically across storage backends: local files are not exposed as 205 unauthenticated static paths, and signed GCS URLs never cross the browser 206 boundary. A file that exists but is not visible to the current viewer 207 returns `404` rather than `403` to avoid revealing the file's existence. 208 Byte downloads are limited to 32 MiB (33,554,432 bytes). The storage provider 209 enforces this limit on actual content, independently of stored size metadata. 210 Larger content returns HTTP `413` with error code `content_too_large`. 211 212 Args: 213 file: File ID (`fil_...`) of the file to download. 214 215 Returns: 216 Raw binary content of the file, served with the file's stored MIME type. 217 """ 218 return await self._http.request_raw(f"/api/v1/files/{file}/download") 219 220 async def org_logo(self, file: str, token: str) -> dict[str, str]: 221 """ 222 Fetch an org logo image 223 Returns the raw image bytes for an organization's logo identified by `file`. 224 This endpoint backs the `org_logo.url` field of catalog payloads (such as 225 `GET /api/v1/solutions`), which anonymous consumers the public marketplace's 226 page cache, OpenGraph scrapers may hold far longer than a signed storage URL 227 lives. Authorization is performed via a short, stable capability `token` rather 228 than an HTTP header, so the URL never expires. 229 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 230 but it is invalidated when the org's logo is replaced or removed shared caches 231 may continue serving the old image until the `Cache-Control` max-age of one hour 232 elapses. The endpoint never redirects to a signed storage URL; bytes are served 233 inline so behavior is consistent across storage backends. 234 All failure modes invalid file ID, invalid token, file not currently referenced 235 as an org logo return a uniform `404` to avoid acting as an existence oracle. 236 237 Args: 238 file: File ID of the org's logo (`fil_...`). Must be currently set as an organization's logo within the same app. 239 token: HMAC capability token authorizing access to this specific file. Obtained from the `org_logo.url` minted when the logo was serialized. 240 241 Returns: 242 Raw image bytes of the org logo, served with the file's original content type. 243 """ 244 query: dict[str, object] = {} 245 query["token"] = token 246 return await self._http.request_raw(f"/api/v1/files/{file}/org_logo", query=query) 247 248 async def share(self, file: str, token: str) -> dict[str, str]: 249 """ 250 Fetch a publicly shared file 251 Returns the raw image bytes for a file that was explicitly shared for public 252 access, identified by `file`. This endpoint is designed for consumers that hold 253 a URL far longer than a signed storage URL lives GitHub PR bodies (whose camo 254 image proxy re-fetches from the origin URL), wikis, and issue trackers and 255 fetch it via plain GET requests without bearer token support. Authorization is 256 performed via a short, stable capability `token` rather than an HTTP header. 257 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 258 but it is invalidated when sharing is turned off for the file (`share: false` on 259 the file update endpoint) or the file is deleted shared caches may continue 260 serving the bytes until the `Cache-Control` max-age of one hour elapses. The 261 endpoint never redirects to a signed storage URL; bytes are served inline so 262 behavior is consistent across storage backends. Only image content types are 263 served. 264 All failure modes invalid file ID, invalid token, file not currently shared 265 return a uniform `404` to avoid acting as an existence oracle. 266 267 Args: 268 file: File ID of the shared file (`fil_...`). The file must currently be marked as publicly shared. 269 token: HMAC capability token authorizing access to this specific file. Obtained from the `share_url` returned when the file was uploaded with `share: true`. 270 271 Returns: 272 Raw image bytes of the shared file, served with the file's original content type. 273 """ 274 query: dict[str, object] = {} 275 query["token"] = token 276 return await self._http.request_raw(f"/api/v1/files/{file}/share", query=query)
86 async def create(self, input: FileCreateInput) -> StorageFile: 87 """ 88 Upload a file 89 Creates a new file from base64-encoded content and returns the resulting file object, 90 including a signed download URL. Use this endpoint to store images, documents, or 91 other binary assets that can then be referenced by agents, teams, or users. 92 The JSON body uses Platform's default 8,000,000-byte parser budget; the 93 an upstream proxy in front of Platform may have a separate 32 MiB request cap. Base64 requires 94 `4 * ceil(binary_bytes / 3)` bytes, plus the UTF-8 JSON envelope (including 95 filename, owner IDs, escaping and other fields). For an envelope of E bytes, 96 budget at most `3 * floor((8,000,000 - E) / 4)` binary bytes: less than 97 6,000,000 bytes (about 5.72 MiB). Do not rely on parser chunk overshoot. 98 Oversized JSON requests are rejected with HTTP 413 before upload processing. 99 App scope is derived from the authenticated viewer's bearer token or publishable key. 100 You may optionally associate the file with an organization, team, user, or agent by 101 passing the corresponding ID. If no owner is specified and the viewer is a user, the 102 file is automatically attributed to that user. 103 Pass `share: true` to additionally mint a stable public URL for the file 104 (returned as `share_url`), fetchable by anyone without authentication for 105 example to embed an uploaded image in a GitHub PR body or other external 106 markdown. The URL does not expire. Sharing is revoked by setting 107 `share: false` on `PATCH /api/v1/files/:file` with the same credential 108 (or `archastro update file <id> --unshare`); re-enabling sharing 109 reactivates previously issued URLs. Only image content types can be 110 shared. 111 Returns `422` when the `data` field is not valid base64, the changeset is 112 invalid, or `share` is requested for a non-image content type. 113 Returns `403` when the request lacks the required app scope. 114 115 Args: 116 input: Request body. 117 input.acl: Access control list for the file. Supports explicit `read` and `write` grants to users, teams, organizations, organization roles, agents, or everyone. 118 input.agent: Agent ID (`agi_...`) to associate with this file. When provided, the file's organization is derived from the agent. 119 input.content_type: MIME type of the file, e.g. `"image/png"` or `"application/pdf"`. 120 input.data: Base64-encoded binary content of the file to upload. 121 input.filename: Original filename including extension, e.g. `"avatar.png"`. 122 input.org: Organization ID (`org_...`) to associate with this file. Optional; defaults to the viewer's organization when omitted. 123 input.share: When `true`, marks the file publicly shareable and returns a stable, non-expiring `share_url` fetchable without authentication. Only image content types can be shared. 124 input.team: Team ID (`tem_...`) that owns this file. Takes precedence over `user` when both are provided. 125 input.user: User ID (`usr_...`) that owns this file. Defaults to the authenticated user when neither `user` nor `team` is specified. 126 127 Returns: 128 The newly created file, including a signed download URL. 129 """ 130 return await self._http.request( 131 "/api/v1/files", 132 method="POST", 133 body=input, 134 response_type=StorageFile, 135 )
Upload a file
Creates a new file from base64-encoded content and returns the resulting file object,
including a signed download URL. Use this endpoint to store images, documents, or
other binary assets that can then be referenced by agents, teams, or users.
The JSON body uses Platform's default 8,000,000-byte parser budget; the
an upstream proxy in front of Platform may have a separate 32 MiB request cap. Base64 requires
4 * ceil(binary_bytes / 3) bytes, plus the UTF-8 JSON envelope (including
filename, owner IDs, escaping and other fields). For an envelope of E bytes,
budget at most 3 * floor((8,000,000 - E) / 4) binary bytes: less than
6,000,000 bytes (about 5.72 MiB). Do not rely on parser chunk overshoot.
Oversized JSON requests are rejected with HTTP 413 before upload processing.
App scope is derived from the authenticated viewer's bearer token or publishable key.
You may optionally associate the file with an organization, team, user, or agent by
passing the corresponding ID. If no owner is specified and the viewer is a user, the
file is automatically attributed to that user.
Pass share: true to additionally mint a stable public URL for the file
(returned as share_url), fetchable by anyone without authentication for
example to embed an uploaded image in a GitHub PR body or other external
markdown. The URL does not expire. Sharing is revoked by setting
share: false on PATCH /api/v1/files/:file with the same credential
(or archastro update file <id> --unshare); re-enabling sharing
reactivates previously issued URLs. Only image content types can be
shared.
Returns 422 when the data field is not valid base64, the changeset is
invalid, or share is requested for a non-image content type.
Returns 403 when the request lacks the required app scope.
Arguments:
- input: Request body.
- input.acl: Access control list for the file. Supports explicit
readandwritegrants to users, teams, organizations, organization roles, agents, or everyone. - input.agent: Agent ID (
agi_...) to associate with this file. When provided, the file's organization is derived from the agent. - input.content_type: MIME type of the file, e.g.
"image/png"or"application/pdf". - input.data: Base64-encoded binary content of the file to upload.
- input.filename: Original filename including extension, e.g.
"avatar.png". - input.org: Organization ID (
org_...) to associate with this file. Optional; defaults to the viewer's organization when omitted. - input.share: When
true, marks the file publicly shareable and returns a stable, non-expiringshare_urlfetchable without authentication. Only image content types can be shared. - input.team: Team ID (
tem_...) that owns this file. Takes precedence overuserwhen both are provided. - input.user: User ID (
usr_...) that owns this file. Defaults to the authenticated user when neitherusernorteamis specified.
Returns:
The newly created file, including a signed download URL.
137 async def update(self, file: str, input: FileUpdateInput) -> StorageFile: 138 """ 139 Update a file 140 Updates mutable fields of an existing file. Only the fields you supply are 141 changed; omitted fields retain their current values. The file's stored content 142 and `content_type` cannot be changed after creation. 143 This endpoint is the companion to `share: true` on file upload: the same 144 credential that granted public sharing can revoke it here with `share: false` 145 (or grant it later with `share: true`; only image content types can be 146 shared, and re-enabling sharing reactivates any previously issued share 147 URLs). App scope is derived from the authenticated viewer, matching upload. 148 A file that exists but is not visible to the current viewer returns `404` 149 rather than `403` to avoid revealing the file's existence. 150 151 Args: 152 file: File ID (`fil_...`) of the file to update. 153 input: Request body. 154 input.filename: New name for the file, including extension, e.g. `"report_v2.pdf"`. Omit to leave the current filename unchanged. 155 input.provider_metadata: Arbitrary key-value map of provider-specific metadata to store alongside the file. Replaces the entire existing `provider_metadata` map. Omit to leave it unchanged. 156 input.share: Set `true` to mark the file publicly shareable via its stable `share_url` (image content types only), or `false` to revoke public sharing. Re-enabling sharing reactivates any previously issued share URLs for the file. Omit to leave sharing unchanged. 157 158 Returns: 159 The updated file, including a signed download URL. 160 """ 161 return await self._http.request( 162 f"/api/v1/files/{file}", 163 method="PATCH", 164 body=input, 165 response_type=StorageFile, 166 )
Update a file
Updates mutable fields of an existing file. Only the fields you supply are
changed; omitted fields retain their current values. The file's stored content
and content_type cannot be changed after creation.
This endpoint is the companion to share: true on file upload: the same
credential that granted public sharing can revoke it here with share: false
(or grant it later with share: true; only image content types can be
shared, and re-enabling sharing reactivates any previously issued share
URLs). App scope is derived from the authenticated viewer, matching upload.
A file that exists but is not visible to the current viewer returns 404
rather than 403 to avoid revealing the file's existence.
Arguments:
- file: File ID (
fil_...) of the file to update. - input: Request body.
- input.filename: New name for the file, including extension, e.g.
"report_v2.pdf". Omit to leave the current filename unchanged. - input.provider_metadata: Arbitrary key-value map of provider-specific metadata to store alongside the file. Replaces the entire existing
provider_metadatamap. Omit to leave it unchanged. - input.share: Set
trueto mark the file publicly shareable via its stableshare_url(image content types only), orfalseto revoke public sharing. Re-enabling sharing reactivates any previously issued share URLs for the file. Omit to leave sharing unchanged.
Returns:
The updated file, including a signed download URL.
168 async def avatar(self, file: str, token: str) -> dict[str, str]: 169 """ 170 Fetch an agent or user avatar image 171 Returns the raw image bytes for an agent's or user's profile picture identified 172 by `file`. Chat messages and integration partners (such as Slack) fetch avatars 173 through it with plain GET requests, without bearer tokens. Authorization is 174 performed via a short, stable capability `token` rather than an HTTP header. 175 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 176 but it is invalidated when the profile picture is replaced or its agent or user 177 is deleted shared caches may continue serving the old image until the 178 `Cache-Control` max-age of one hour elapses. The endpoint never redirects to 179 a signed storage URL; bytes are served inline so behavior is consistent across 180 storage backends. 181 All failure modes invalid file ID, invalid token, file not currently referenced 182 as an agent avatar return a uniform `404` to avoid acting as an existence oracle. 183 184 Args: 185 file: File ID of the profile picture (`fil_...`). Must be currently set as an agent's or user's profile picture within the same app. 186 token: HMAC capability token authorizing access to this specific file. Obtained from the avatar URL minted when the profile picture was set. 187 188 Returns: 189 Raw image bytes of the avatar, served with the file's original content type. 190 """ 191 query: dict[str, object] = {} 192 query["token"] = token 193 return await self._http.request_raw(f"/api/v1/files/{file}/avatar", query=query)
Fetch an agent or user avatar image
Returns the raw image bytes for an agent's or user's profile picture identified
by file. Chat messages and integration partners (such as Slack) fetch avatars
through it with plain GET requests, without bearer tokens. Authorization is
performed via a short, stable capability token rather than an HTTP header.
The token is an HMAC-based capability tied to the file ID. It does not expire,
but it is invalidated when the profile picture is replaced or its agent or user
is deleted shared caches may continue serving the old image until the
Cache-Control max-age of one hour elapses. The endpoint never redirects to
a signed storage URL; bytes are served inline so behavior is consistent across
storage backends.
All failure modes invalid file ID, invalid token, file not currently referenced
as an agent avatar return a uniform 404 to avoid acting as an existence oracle.
Arguments:
- file: File ID of the profile picture (
fil_...). Must be currently set as an agent's or user's profile picture within the same app. - token: HMAC capability token authorizing access to this specific file. Obtained from the avatar URL minted when the profile picture was set.
Returns:
Raw image bytes of the avatar, served with the file's original content type.
195 async def download(self, file: str) -> dict[str, str]: 196 """ 197 Download a file's bytes 198 Returns the raw binary content of a file the authenticated viewer may see. 199 The response `Content-Type` header reflects the file's stored MIME type and 200 `Content-Disposition` names the file as an attachment, so a browser can hand 201 the body to the download manager directly. 202 Unlike `Show` (which mints a storage URL the browser must resolve itself), 203 this endpoint serves bytes inline through the authenticated API mount, so it 204 behaves identically across storage backends: local files are not exposed as 205 unauthenticated static paths, and signed GCS URLs never cross the browser 206 boundary. A file that exists but is not visible to the current viewer 207 returns `404` rather than `403` to avoid revealing the file's existence. 208 Byte downloads are limited to 32 MiB (33,554,432 bytes). The storage provider 209 enforces this limit on actual content, independently of stored size metadata. 210 Larger content returns HTTP `413` with error code `content_too_large`. 211 212 Args: 213 file: File ID (`fil_...`) of the file to download. 214 215 Returns: 216 Raw binary content of the file, served with the file's stored MIME type. 217 """ 218 return await self._http.request_raw(f"/api/v1/files/{file}/download")
Download a file's bytes
Returns the raw binary content of a file the authenticated viewer may see.
The response Content-Type header reflects the file's stored MIME type and
Content-Disposition names the file as an attachment, so a browser can hand
the body to the download manager directly.
Unlike Show (which mints a storage URL the browser must resolve itself),
this endpoint serves bytes inline through the authenticated API mount, so it
behaves identically across storage backends: local files are not exposed as
unauthenticated static paths, and signed GCS URLs never cross the browser
boundary. A file that exists but is not visible to the current viewer
returns 404 rather than 403 to avoid revealing the file's existence.
Byte downloads are limited to 32 MiB (33,554,432 bytes). The storage provider
enforces this limit on actual content, independently of stored size metadata.
Larger content returns HTTP 413 with error code content_too_large.
Arguments:
- file: File ID (
fil_...) of the file to download.
Returns:
Raw binary content of the file, served with the file's stored MIME type.
220 async def org_logo(self, file: str, token: str) -> dict[str, str]: 221 """ 222 Fetch an org logo image 223 Returns the raw image bytes for an organization's logo identified by `file`. 224 This endpoint backs the `org_logo.url` field of catalog payloads (such as 225 `GET /api/v1/solutions`), which anonymous consumers the public marketplace's 226 page cache, OpenGraph scrapers may hold far longer than a signed storage URL 227 lives. Authorization is performed via a short, stable capability `token` rather 228 than an HTTP header, so the URL never expires. 229 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 230 but it is invalidated when the org's logo is replaced or removed shared caches 231 may continue serving the old image until the `Cache-Control` max-age of one hour 232 elapses. The endpoint never redirects to a signed storage URL; bytes are served 233 inline so behavior is consistent across storage backends. 234 All failure modes invalid file ID, invalid token, file not currently referenced 235 as an org logo return a uniform `404` to avoid acting as an existence oracle. 236 237 Args: 238 file: File ID of the org's logo (`fil_...`). Must be currently set as an organization's logo within the same app. 239 token: HMAC capability token authorizing access to this specific file. Obtained from the `org_logo.url` minted when the logo was serialized. 240 241 Returns: 242 Raw image bytes of the org logo, served with the file's original content type. 243 """ 244 query: dict[str, object] = {} 245 query["token"] = token 246 return await self._http.request_raw(f"/api/v1/files/{file}/org_logo", query=query)
Fetch an org logo image
Returns the raw image bytes for an organization's logo identified by file.
This endpoint backs the org_logo.url field of catalog payloads (such as
GET /api/v1/solutions), which anonymous consumers the public marketplace's
page cache, OpenGraph scrapers may hold far longer than a signed storage URL
lives. Authorization is performed via a short, stable capability token rather
than an HTTP header, so the URL never expires.
The token is an HMAC-based capability tied to the file ID. It does not expire,
but it is invalidated when the org's logo is replaced or removed shared caches
may continue serving the old image until the Cache-Control max-age of one hour
elapses. The endpoint never redirects to a signed storage URL; bytes are served
inline so behavior is consistent across storage backends.
All failure modes invalid file ID, invalid token, file not currently referenced
as an org logo return a uniform 404 to avoid acting as an existence oracle.
Arguments:
- file: File ID of the org's logo (
fil_...). Must be currently set as an organization's logo within the same app. - token: HMAC capability token authorizing access to this specific file. Obtained from the
org_logo.urlminted when the logo was serialized.
Returns:
Raw image bytes of the org logo, served with the file's original content type.
279class FileResource: 280 def __init__(self, http: SyncHttpClient): 281 self._http = http 282 283 def create(self, input: FileCreateInput) -> StorageFile: 284 """ 285 Upload a file 286 Creates a new file from base64-encoded content and returns the resulting file object, 287 including a signed download URL. Use this endpoint to store images, documents, or 288 other binary assets that can then be referenced by agents, teams, or users. 289 The JSON body uses Platform's default 8,000,000-byte parser budget; the 290 an upstream proxy in front of Platform may have a separate 32 MiB request cap. Base64 requires 291 `4 * ceil(binary_bytes / 3)` bytes, plus the UTF-8 JSON envelope (including 292 filename, owner IDs, escaping and other fields). For an envelope of E bytes, 293 budget at most `3 * floor((8,000,000 - E) / 4)` binary bytes: less than 294 6,000,000 bytes (about 5.72 MiB). Do not rely on parser chunk overshoot. 295 Oversized JSON requests are rejected with HTTP 413 before upload processing. 296 App scope is derived from the authenticated viewer's bearer token or publishable key. 297 You may optionally associate the file with an organization, team, user, or agent by 298 passing the corresponding ID. If no owner is specified and the viewer is a user, the 299 file is automatically attributed to that user. 300 Pass `share: true` to additionally mint a stable public URL for the file 301 (returned as `share_url`), fetchable by anyone without authentication for 302 example to embed an uploaded image in a GitHub PR body or other external 303 markdown. The URL does not expire. Sharing is revoked by setting 304 `share: false` on `PATCH /api/v1/files/:file` with the same credential 305 (or `archastro update file <id> --unshare`); re-enabling sharing 306 reactivates previously issued URLs. Only image content types can be 307 shared. 308 Returns `422` when the `data` field is not valid base64, the changeset is 309 invalid, or `share` is requested for a non-image content type. 310 Returns `403` when the request lacks the required app scope. 311 312 Args: 313 input: Request body. 314 input.acl: Access control list for the file. Supports explicit `read` and `write` grants to users, teams, organizations, organization roles, agents, or everyone. 315 input.agent: Agent ID (`agi_...`) to associate with this file. When provided, the file's organization is derived from the agent. 316 input.content_type: MIME type of the file, e.g. `"image/png"` or `"application/pdf"`. 317 input.data: Base64-encoded binary content of the file to upload. 318 input.filename: Original filename including extension, e.g. `"avatar.png"`. 319 input.org: Organization ID (`org_...`) to associate with this file. Optional; defaults to the viewer's organization when omitted. 320 input.share: When `true`, marks the file publicly shareable and returns a stable, non-expiring `share_url` fetchable without authentication. Only image content types can be shared. 321 input.team: Team ID (`tem_...`) that owns this file. Takes precedence over `user` when both are provided. 322 input.user: User ID (`usr_...`) that owns this file. Defaults to the authenticated user when neither `user` nor `team` is specified. 323 324 Returns: 325 The newly created file, including a signed download URL. 326 """ 327 return self._http.request( 328 "/api/v1/files", 329 method="POST", 330 body=input, 331 response_type=StorageFile, 332 ) 333 334 def update(self, file: str, input: FileUpdateInput) -> StorageFile: 335 """ 336 Update a file 337 Updates mutable fields of an existing file. Only the fields you supply are 338 changed; omitted fields retain their current values. The file's stored content 339 and `content_type` cannot be changed after creation. 340 This endpoint is the companion to `share: true` on file upload: the same 341 credential that granted public sharing can revoke it here with `share: false` 342 (or grant it later with `share: true`; only image content types can be 343 shared, and re-enabling sharing reactivates any previously issued share 344 URLs). App scope is derived from the authenticated viewer, matching upload. 345 A file that exists but is not visible to the current viewer returns `404` 346 rather than `403` to avoid revealing the file's existence. 347 348 Args: 349 file: File ID (`fil_...`) of the file to update. 350 input: Request body. 351 input.filename: New name for the file, including extension, e.g. `"report_v2.pdf"`. Omit to leave the current filename unchanged. 352 input.provider_metadata: Arbitrary key-value map of provider-specific metadata to store alongside the file. Replaces the entire existing `provider_metadata` map. Omit to leave it unchanged. 353 input.share: Set `true` to mark the file publicly shareable via its stable `share_url` (image content types only), or `false` to revoke public sharing. Re-enabling sharing reactivates any previously issued share URLs for the file. Omit to leave sharing unchanged. 354 355 Returns: 356 The updated file, including a signed download URL. 357 """ 358 return self._http.request( 359 f"/api/v1/files/{file}", 360 method="PATCH", 361 body=input, 362 response_type=StorageFile, 363 ) 364 365 def avatar(self, file: str, token: str) -> dict[str, str]: 366 """ 367 Fetch an agent or user avatar image 368 Returns the raw image bytes for an agent's or user's profile picture identified 369 by `file`. Chat messages and integration partners (such as Slack) fetch avatars 370 through it with plain GET requests, without bearer tokens. Authorization is 371 performed via a short, stable capability `token` rather than an HTTP header. 372 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 373 but it is invalidated when the profile picture is replaced or its agent or user 374 is deleted shared caches may continue serving the old image until the 375 `Cache-Control` max-age of one hour elapses. The endpoint never redirects to 376 a signed storage URL; bytes are served inline so behavior is consistent across 377 storage backends. 378 All failure modes invalid file ID, invalid token, file not currently referenced 379 as an agent avatar return a uniform `404` to avoid acting as an existence oracle. 380 381 Args: 382 file: File ID of the profile picture (`fil_...`). Must be currently set as an agent's or user's profile picture within the same app. 383 token: HMAC capability token authorizing access to this specific file. Obtained from the avatar URL minted when the profile picture was set. 384 385 Returns: 386 Raw image bytes of the avatar, served with the file's original content type. 387 """ 388 query: dict[str, object] = {} 389 query["token"] = token 390 return self._http.request_raw(f"/api/v1/files/{file}/avatar", query=query) 391 392 def download(self, file: str) -> dict[str, str]: 393 """ 394 Download a file's bytes 395 Returns the raw binary content of a file the authenticated viewer may see. 396 The response `Content-Type` header reflects the file's stored MIME type and 397 `Content-Disposition` names the file as an attachment, so a browser can hand 398 the body to the download manager directly. 399 Unlike `Show` (which mints a storage URL the browser must resolve itself), 400 this endpoint serves bytes inline through the authenticated API mount, so it 401 behaves identically across storage backends: local files are not exposed as 402 unauthenticated static paths, and signed GCS URLs never cross the browser 403 boundary. A file that exists but is not visible to the current viewer 404 returns `404` rather than `403` to avoid revealing the file's existence. 405 Byte downloads are limited to 32 MiB (33,554,432 bytes). The storage provider 406 enforces this limit on actual content, independently of stored size metadata. 407 Larger content returns HTTP `413` with error code `content_too_large`. 408 409 Args: 410 file: File ID (`fil_...`) of the file to download. 411 412 Returns: 413 Raw binary content of the file, served with the file's stored MIME type. 414 """ 415 return self._http.request_raw(f"/api/v1/files/{file}/download") 416 417 def org_logo(self, file: str, token: str) -> dict[str, str]: 418 """ 419 Fetch an org logo image 420 Returns the raw image bytes for an organization's logo identified by `file`. 421 This endpoint backs the `org_logo.url` field of catalog payloads (such as 422 `GET /api/v1/solutions`), which anonymous consumers the public marketplace's 423 page cache, OpenGraph scrapers may hold far longer than a signed storage URL 424 lives. Authorization is performed via a short, stable capability `token` rather 425 than an HTTP header, so the URL never expires. 426 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 427 but it is invalidated when the org's logo is replaced or removed shared caches 428 may continue serving the old image until the `Cache-Control` max-age of one hour 429 elapses. The endpoint never redirects to a signed storage URL; bytes are served 430 inline so behavior is consistent across storage backends. 431 All failure modes invalid file ID, invalid token, file not currently referenced 432 as an org logo return a uniform `404` to avoid acting as an existence oracle. 433 434 Args: 435 file: File ID of the org's logo (`fil_...`). Must be currently set as an organization's logo within the same app. 436 token: HMAC capability token authorizing access to this specific file. Obtained from the `org_logo.url` minted when the logo was serialized. 437 438 Returns: 439 Raw image bytes of the org logo, served with the file's original content type. 440 """ 441 query: dict[str, object] = {} 442 query["token"] = token 443 return self._http.request_raw(f"/api/v1/files/{file}/org_logo", query=query) 444 445 def share(self, file: str, token: str) -> dict[str, str]: 446 """ 447 Fetch a publicly shared file 448 Returns the raw image bytes for a file that was explicitly shared for public 449 access, identified by `file`. This endpoint is designed for consumers that hold 450 a URL far longer than a signed storage URL lives GitHub PR bodies (whose camo 451 image proxy re-fetches from the origin URL), wikis, and issue trackers and 452 fetch it via plain GET requests without bearer token support. Authorization is 453 performed via a short, stable capability `token` rather than an HTTP header. 454 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 455 but it is invalidated when sharing is turned off for the file (`share: false` on 456 the file update endpoint) or the file is deleted shared caches may continue 457 serving the bytes until the `Cache-Control` max-age of one hour elapses. The 458 endpoint never redirects to a signed storage URL; bytes are served inline so 459 behavior is consistent across storage backends. Only image content types are 460 served. 461 All failure modes invalid file ID, invalid token, file not currently shared 462 return a uniform `404` to avoid acting as an existence oracle. 463 464 Args: 465 file: File ID of the shared file (`fil_...`). The file must currently be marked as publicly shared. 466 token: HMAC capability token authorizing access to this specific file. Obtained from the `share_url` returned when the file was uploaded with `share: true`. 467 468 Returns: 469 Raw image bytes of the shared file, served with the file's original content type. 470 """ 471 query: dict[str, object] = {} 472 query["token"] = token 473 return self._http.request_raw(f"/api/v1/files/{file}/share", query=query)
283 def create(self, input: FileCreateInput) -> StorageFile: 284 """ 285 Upload a file 286 Creates a new file from base64-encoded content and returns the resulting file object, 287 including a signed download URL. Use this endpoint to store images, documents, or 288 other binary assets that can then be referenced by agents, teams, or users. 289 The JSON body uses Platform's default 8,000,000-byte parser budget; the 290 an upstream proxy in front of Platform may have a separate 32 MiB request cap. Base64 requires 291 `4 * ceil(binary_bytes / 3)` bytes, plus the UTF-8 JSON envelope (including 292 filename, owner IDs, escaping and other fields). For an envelope of E bytes, 293 budget at most `3 * floor((8,000,000 - E) / 4)` binary bytes: less than 294 6,000,000 bytes (about 5.72 MiB). Do not rely on parser chunk overshoot. 295 Oversized JSON requests are rejected with HTTP 413 before upload processing. 296 App scope is derived from the authenticated viewer's bearer token or publishable key. 297 You may optionally associate the file with an organization, team, user, or agent by 298 passing the corresponding ID. If no owner is specified and the viewer is a user, the 299 file is automatically attributed to that user. 300 Pass `share: true` to additionally mint a stable public URL for the file 301 (returned as `share_url`), fetchable by anyone without authentication for 302 example to embed an uploaded image in a GitHub PR body or other external 303 markdown. The URL does not expire. Sharing is revoked by setting 304 `share: false` on `PATCH /api/v1/files/:file` with the same credential 305 (or `archastro update file <id> --unshare`); re-enabling sharing 306 reactivates previously issued URLs. Only image content types can be 307 shared. 308 Returns `422` when the `data` field is not valid base64, the changeset is 309 invalid, or `share` is requested for a non-image content type. 310 Returns `403` when the request lacks the required app scope. 311 312 Args: 313 input: Request body. 314 input.acl: Access control list for the file. Supports explicit `read` and `write` grants to users, teams, organizations, organization roles, agents, or everyone. 315 input.agent: Agent ID (`agi_...`) to associate with this file. When provided, the file's organization is derived from the agent. 316 input.content_type: MIME type of the file, e.g. `"image/png"` or `"application/pdf"`. 317 input.data: Base64-encoded binary content of the file to upload. 318 input.filename: Original filename including extension, e.g. `"avatar.png"`. 319 input.org: Organization ID (`org_...`) to associate with this file. Optional; defaults to the viewer's organization when omitted. 320 input.share: When `true`, marks the file publicly shareable and returns a stable, non-expiring `share_url` fetchable without authentication. Only image content types can be shared. 321 input.team: Team ID (`tem_...`) that owns this file. Takes precedence over `user` when both are provided. 322 input.user: User ID (`usr_...`) that owns this file. Defaults to the authenticated user when neither `user` nor `team` is specified. 323 324 Returns: 325 The newly created file, including a signed download URL. 326 """ 327 return self._http.request( 328 "/api/v1/files", 329 method="POST", 330 body=input, 331 response_type=StorageFile, 332 )
Upload a file
Creates a new file from base64-encoded content and returns the resulting file object,
including a signed download URL. Use this endpoint to store images, documents, or
other binary assets that can then be referenced by agents, teams, or users.
The JSON body uses Platform's default 8,000,000-byte parser budget; the
an upstream proxy in front of Platform may have a separate 32 MiB request cap. Base64 requires
4 * ceil(binary_bytes / 3) bytes, plus the UTF-8 JSON envelope (including
filename, owner IDs, escaping and other fields). For an envelope of E bytes,
budget at most 3 * floor((8,000,000 - E) / 4) binary bytes: less than
6,000,000 bytes (about 5.72 MiB). Do not rely on parser chunk overshoot.
Oversized JSON requests are rejected with HTTP 413 before upload processing.
App scope is derived from the authenticated viewer's bearer token or publishable key.
You may optionally associate the file with an organization, team, user, or agent by
passing the corresponding ID. If no owner is specified and the viewer is a user, the
file is automatically attributed to that user.
Pass share: true to additionally mint a stable public URL for the file
(returned as share_url), fetchable by anyone without authentication for
example to embed an uploaded image in a GitHub PR body or other external
markdown. The URL does not expire. Sharing is revoked by setting
share: false on PATCH /api/v1/files/:file with the same credential
(or archastro update file <id> --unshare); re-enabling sharing
reactivates previously issued URLs. Only image content types can be
shared.
Returns 422 when the data field is not valid base64, the changeset is
invalid, or share is requested for a non-image content type.
Returns 403 when the request lacks the required app scope.
Arguments:
- input: Request body.
- input.acl: Access control list for the file. Supports explicit
readandwritegrants to users, teams, organizations, organization roles, agents, or everyone. - input.agent: Agent ID (
agi_...) to associate with this file. When provided, the file's organization is derived from the agent. - input.content_type: MIME type of the file, e.g.
"image/png"or"application/pdf". - input.data: Base64-encoded binary content of the file to upload.
- input.filename: Original filename including extension, e.g.
"avatar.png". - input.org: Organization ID (
org_...) to associate with this file. Optional; defaults to the viewer's organization when omitted. - input.share: When
true, marks the file publicly shareable and returns a stable, non-expiringshare_urlfetchable without authentication. Only image content types can be shared. - input.team: Team ID (
tem_...) that owns this file. Takes precedence overuserwhen both are provided. - input.user: User ID (
usr_...) that owns this file. Defaults to the authenticated user when neitherusernorteamis specified.
Returns:
The newly created file, including a signed download URL.
334 def update(self, file: str, input: FileUpdateInput) -> StorageFile: 335 """ 336 Update a file 337 Updates mutable fields of an existing file. Only the fields you supply are 338 changed; omitted fields retain their current values. The file's stored content 339 and `content_type` cannot be changed after creation. 340 This endpoint is the companion to `share: true` on file upload: the same 341 credential that granted public sharing can revoke it here with `share: false` 342 (or grant it later with `share: true`; only image content types can be 343 shared, and re-enabling sharing reactivates any previously issued share 344 URLs). App scope is derived from the authenticated viewer, matching upload. 345 A file that exists but is not visible to the current viewer returns `404` 346 rather than `403` to avoid revealing the file's existence. 347 348 Args: 349 file: File ID (`fil_...`) of the file to update. 350 input: Request body. 351 input.filename: New name for the file, including extension, e.g. `"report_v2.pdf"`. Omit to leave the current filename unchanged. 352 input.provider_metadata: Arbitrary key-value map of provider-specific metadata to store alongside the file. Replaces the entire existing `provider_metadata` map. Omit to leave it unchanged. 353 input.share: Set `true` to mark the file publicly shareable via its stable `share_url` (image content types only), or `false` to revoke public sharing. Re-enabling sharing reactivates any previously issued share URLs for the file. Omit to leave sharing unchanged. 354 355 Returns: 356 The updated file, including a signed download URL. 357 """ 358 return self._http.request( 359 f"/api/v1/files/{file}", 360 method="PATCH", 361 body=input, 362 response_type=StorageFile, 363 )
Update a file
Updates mutable fields of an existing file. Only the fields you supply are
changed; omitted fields retain their current values. The file's stored content
and content_type cannot be changed after creation.
This endpoint is the companion to share: true on file upload: the same
credential that granted public sharing can revoke it here with share: false
(or grant it later with share: true; only image content types can be
shared, and re-enabling sharing reactivates any previously issued share
URLs). App scope is derived from the authenticated viewer, matching upload.
A file that exists but is not visible to the current viewer returns 404
rather than 403 to avoid revealing the file's existence.
Arguments:
- file: File ID (
fil_...) of the file to update. - input: Request body.
- input.filename: New name for the file, including extension, e.g.
"report_v2.pdf". Omit to leave the current filename unchanged. - input.provider_metadata: Arbitrary key-value map of provider-specific metadata to store alongside the file. Replaces the entire existing
provider_metadatamap. Omit to leave it unchanged. - input.share: Set
trueto mark the file publicly shareable via its stableshare_url(image content types only), orfalseto revoke public sharing. Re-enabling sharing reactivates any previously issued share URLs for the file. Omit to leave sharing unchanged.
Returns:
The updated file, including a signed download URL.
365 def avatar(self, file: str, token: str) -> dict[str, str]: 366 """ 367 Fetch an agent or user avatar image 368 Returns the raw image bytes for an agent's or user's profile picture identified 369 by `file`. Chat messages and integration partners (such as Slack) fetch avatars 370 through it with plain GET requests, without bearer tokens. Authorization is 371 performed via a short, stable capability `token` rather than an HTTP header. 372 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 373 but it is invalidated when the profile picture is replaced or its agent or user 374 is deleted shared caches may continue serving the old image until the 375 `Cache-Control` max-age of one hour elapses. The endpoint never redirects to 376 a signed storage URL; bytes are served inline so behavior is consistent across 377 storage backends. 378 All failure modes invalid file ID, invalid token, file not currently referenced 379 as an agent avatar return a uniform `404` to avoid acting as an existence oracle. 380 381 Args: 382 file: File ID of the profile picture (`fil_...`). Must be currently set as an agent's or user's profile picture within the same app. 383 token: HMAC capability token authorizing access to this specific file. Obtained from the avatar URL minted when the profile picture was set. 384 385 Returns: 386 Raw image bytes of the avatar, served with the file's original content type. 387 """ 388 query: dict[str, object] = {} 389 query["token"] = token 390 return self._http.request_raw(f"/api/v1/files/{file}/avatar", query=query)
Fetch an agent or user avatar image
Returns the raw image bytes for an agent's or user's profile picture identified
by file. Chat messages and integration partners (such as Slack) fetch avatars
through it with plain GET requests, without bearer tokens. Authorization is
performed via a short, stable capability token rather than an HTTP header.
The token is an HMAC-based capability tied to the file ID. It does not expire,
but it is invalidated when the profile picture is replaced or its agent or user
is deleted shared caches may continue serving the old image until the
Cache-Control max-age of one hour elapses. The endpoint never redirects to
a signed storage URL; bytes are served inline so behavior is consistent across
storage backends.
All failure modes invalid file ID, invalid token, file not currently referenced
as an agent avatar return a uniform 404 to avoid acting as an existence oracle.
Arguments:
- file: File ID of the profile picture (
fil_...). Must be currently set as an agent's or user's profile picture within the same app. - token: HMAC capability token authorizing access to this specific file. Obtained from the avatar URL minted when the profile picture was set.
Returns:
Raw image bytes of the avatar, served with the file's original content type.
392 def download(self, file: str) -> dict[str, str]: 393 """ 394 Download a file's bytes 395 Returns the raw binary content of a file the authenticated viewer may see. 396 The response `Content-Type` header reflects the file's stored MIME type and 397 `Content-Disposition` names the file as an attachment, so a browser can hand 398 the body to the download manager directly. 399 Unlike `Show` (which mints a storage URL the browser must resolve itself), 400 this endpoint serves bytes inline through the authenticated API mount, so it 401 behaves identically across storage backends: local files are not exposed as 402 unauthenticated static paths, and signed GCS URLs never cross the browser 403 boundary. A file that exists but is not visible to the current viewer 404 returns `404` rather than `403` to avoid revealing the file's existence. 405 Byte downloads are limited to 32 MiB (33,554,432 bytes). The storage provider 406 enforces this limit on actual content, independently of stored size metadata. 407 Larger content returns HTTP `413` with error code `content_too_large`. 408 409 Args: 410 file: File ID (`fil_...`) of the file to download. 411 412 Returns: 413 Raw binary content of the file, served with the file's stored MIME type. 414 """ 415 return self._http.request_raw(f"/api/v1/files/{file}/download")
Download a file's bytes
Returns the raw binary content of a file the authenticated viewer may see.
The response Content-Type header reflects the file's stored MIME type and
Content-Disposition names the file as an attachment, so a browser can hand
the body to the download manager directly.
Unlike Show (which mints a storage URL the browser must resolve itself),
this endpoint serves bytes inline through the authenticated API mount, so it
behaves identically across storage backends: local files are not exposed as
unauthenticated static paths, and signed GCS URLs never cross the browser
boundary. A file that exists but is not visible to the current viewer
returns 404 rather than 403 to avoid revealing the file's existence.
Byte downloads are limited to 32 MiB (33,554,432 bytes). The storage provider
enforces this limit on actual content, independently of stored size metadata.
Larger content returns HTTP 413 with error code content_too_large.
Arguments:
- file: File ID (
fil_...) of the file to download.
Returns:
Raw binary content of the file, served with the file's stored MIME type.
417 def org_logo(self, file: str, token: str) -> dict[str, str]: 418 """ 419 Fetch an org logo image 420 Returns the raw image bytes for an organization's logo identified by `file`. 421 This endpoint backs the `org_logo.url` field of catalog payloads (such as 422 `GET /api/v1/solutions`), which anonymous consumers the public marketplace's 423 page cache, OpenGraph scrapers may hold far longer than a signed storage URL 424 lives. Authorization is performed via a short, stable capability `token` rather 425 than an HTTP header, so the URL never expires. 426 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 427 but it is invalidated when the org's logo is replaced or removed shared caches 428 may continue serving the old image until the `Cache-Control` max-age of one hour 429 elapses. The endpoint never redirects to a signed storage URL; bytes are served 430 inline so behavior is consistent across storage backends. 431 All failure modes invalid file ID, invalid token, file not currently referenced 432 as an org logo return a uniform `404` to avoid acting as an existence oracle. 433 434 Args: 435 file: File ID of the org's logo (`fil_...`). Must be currently set as an organization's logo within the same app. 436 token: HMAC capability token authorizing access to this specific file. Obtained from the `org_logo.url` minted when the logo was serialized. 437 438 Returns: 439 Raw image bytes of the org logo, served with the file's original content type. 440 """ 441 query: dict[str, object] = {} 442 query["token"] = token 443 return self._http.request_raw(f"/api/v1/files/{file}/org_logo", query=query)
Fetch an org logo image
Returns the raw image bytes for an organization's logo identified by file.
This endpoint backs the org_logo.url field of catalog payloads (such as
GET /api/v1/solutions), which anonymous consumers the public marketplace's
page cache, OpenGraph scrapers may hold far longer than a signed storage URL
lives. Authorization is performed via a short, stable capability token rather
than an HTTP header, so the URL never expires.
The token is an HMAC-based capability tied to the file ID. It does not expire,
but it is invalidated when the org's logo is replaced or removed shared caches
may continue serving the old image until the Cache-Control max-age of one hour
elapses. The endpoint never redirects to a signed storage URL; bytes are served
inline so behavior is consistent across storage backends.
All failure modes invalid file ID, invalid token, file not currently referenced
as an org logo return a uniform 404 to avoid acting as an existence oracle.
Arguments:
- file: File ID of the org's logo (
fil_...). Must be currently set as an organization's logo within the same app. - token: HMAC capability token authorizing access to this specific file. Obtained from the
org_logo.urlminted when the logo was serialized.
Returns:
Raw image bytes of the org logo, served with the file's original content type.