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: 03df018ed706 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 App scope is derived from the authenticated viewer's bearer token or publishable key. 92 You may optionally associate the file with an organization, team, user, or agent by 93 passing the corresponding ID. If no owner is specified and the viewer is a user, the 94 file is automatically attributed to that user. 95 Pass `share: true` to additionally mint a stable public URL for the file 96 (returned as `share_url`), fetchable by anyone without authentication for 97 example to embed an uploaded image in a GitHub PR body or other external 98 markdown. The URL does not expire. Sharing is revoked by setting 99 `share: false` on `PATCH /api/v1/files/:file` with the same credential 100 (or `archastro update file <id> --unshare`); re-enabling sharing 101 reactivates previously issued URLs. Only image content types can be 102 shared. 103 Returns `422` when the `data` field is not valid base64, the changeset is 104 invalid, or `share` is requested for a non-image content type. 105 Returns `403` when the request lacks the required app scope. 106 107 Args: 108 input: Request body. 109 input.acl: Access control list for the file. Supports explicit `read` and `write` grants to users, teams, organizations, organization roles, agents, or everyone. 110 input.agent: Agent ID (`agi_...`) to associate with this file. When provided, the file's organization is derived from the agent. 111 input.content_type: MIME type of the file, e.g. `"image/png"` or `"application/pdf"`. 112 input.data: Base64-encoded binary content of the file to upload. 113 input.filename: Original filename including extension, e.g. `"avatar.png"`. 114 input.org: Organization ID (`org_...`) to associate with this file. Optional; defaults to the viewer's organization when omitted. 115 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. 116 input.team: Team ID (`tem_...`) that owns this file. Takes precedence over `user` when both are provided. 117 input.user: User ID (`usr_...`) that owns this file. Defaults to the authenticated user when neither `user` nor `team` is specified. 118 119 Returns: 120 The newly created file, including a signed download URL. 121 """ 122 return await self._http.request( 123 "/api/v1/files", 124 method="POST", 125 body=input, 126 response_type=StorageFile, 127 ) 128 129 async def update(self, file: str, input: FileUpdateInput) -> StorageFile: 130 """ 131 Update a file 132 Updates mutable fields of an existing file. Only the fields you supply are 133 changed; omitted fields retain their current values. The file's stored content 134 and `content_type` cannot be changed after creation. 135 This endpoint is the companion to `share: true` on file upload: the same 136 credential that granted public sharing can revoke it here with `share: false` 137 (or grant it later with `share: true`; only image content types can be 138 shared, and re-enabling sharing reactivates any previously issued share 139 URLs). App scope is derived from the authenticated viewer, matching upload. 140 A file that exists but is not visible to the current viewer returns `404` 141 rather than `403` to avoid revealing the file's existence. 142 143 Args: 144 file: File ID (`fil_...`) of the file to update. 145 input: Request body. 146 input.filename: New name for the file, including extension, e.g. `"report_v2.pdf"`. Omit to leave the current filename unchanged. 147 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. 148 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. 149 150 Returns: 151 The updated file, including a signed download URL. 152 """ 153 return await self._http.request( 154 f"/api/v1/files/{file}", 155 method="PATCH", 156 body=input, 157 response_type=StorageFile, 158 ) 159 160 async def avatar(self, file: str, token: str) -> dict[str, str]: 161 """ 162 Fetch an agent avatar image 163 Returns the raw image bytes for an agent's profile picture identified by `file`. 164 This endpoint is designed for integration partners (such as Slack) that fetch 165 avatar URLs via plain GET requests without bearer token support. Authorization 166 is performed via a short, stable capability `token` rather than an HTTP header. 167 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 168 but it is invalidated when the agent's profile picture is replaced or the agent is 169 deleted shared caches may continue serving the old image until the 170 `Cache-Control` max-age of one hour elapses. The endpoint never redirects to 171 a signed storage URL; bytes are served inline so behavior is consistent across 172 storage backends. 173 All failure modes invalid file ID, invalid token, file not currently referenced 174 as an agent avatar return a uniform `404` to avoid acting as an existence oracle. 175 176 Args: 177 file: File ID of the agent's profile picture (`fil_...`). Must be currently set as an agent's profile picture within the same app. 178 token: HMAC capability token authorizing access to this specific file. Obtained from the avatar URL minted when the profile picture was set. 179 180 Returns: 181 Raw image bytes of the agent avatar, served with the file's original content type. 182 """ 183 query: dict[str, object] = {} 184 query["token"] = token 185 return await self._http.request_raw(f"/api/v1/files/{file}/avatar", query=query) 186 187 async def org_logo(self, file: str, token: str) -> dict[str, str]: 188 """ 189 Fetch an org logo image 190 Returns the raw image bytes for an organization's logo identified by `file`. 191 This endpoint backs the `org_logo.url` field of catalog payloads (such as 192 `GET /api/v1/solutions`), which anonymous consumers the public marketplace's 193 page cache, OpenGraph scrapers may hold far longer than a signed storage URL 194 lives. Authorization is performed via a short, stable capability `token` rather 195 than an HTTP header, so the URL never expires. 196 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 197 but it is invalidated when the org's logo is replaced or removed shared caches 198 may continue serving the old image until the `Cache-Control` max-age of one hour 199 elapses. The endpoint never redirects to a signed storage URL; bytes are served 200 inline so behavior is consistent across storage backends. 201 All failure modes invalid file ID, invalid token, file not currently referenced 202 as an org logo return a uniform `404` to avoid acting as an existence oracle. 203 204 Args: 205 file: File ID of the org's logo (`fil_...`). Must be currently set as an organization's logo within the same app. 206 token: HMAC capability token authorizing access to this specific file. Obtained from the `org_logo.url` minted when the logo was serialized. 207 208 Returns: 209 Raw image bytes of the org logo, served with the file's original content type. 210 """ 211 query: dict[str, object] = {} 212 query["token"] = token 213 return await self._http.request_raw(f"/api/v1/files/{file}/org_logo", query=query) 214 215 async def share(self, file: str, token: str) -> dict[str, str]: 216 """ 217 Fetch a publicly shared file 218 Returns the raw image bytes for a file that was explicitly shared for public 219 access, identified by `file`. This endpoint is designed for consumers that hold 220 a URL far longer than a signed storage URL lives GitHub PR bodies (whose camo 221 image proxy re-fetches from the origin URL), wikis, and issue trackers and 222 fetch it via plain GET requests without bearer token support. Authorization is 223 performed via a short, stable capability `token` rather than an HTTP header. 224 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 225 but it is invalidated when sharing is turned off for the file (`share: false` on 226 the file update endpoint) or the file is deleted shared caches may continue 227 serving the bytes until the `Cache-Control` max-age of one hour elapses. The 228 endpoint never redirects to a signed storage URL; bytes are served inline so 229 behavior is consistent across storage backends. Only image content types are 230 served. 231 All failure modes invalid file ID, invalid token, file not currently shared 232 return a uniform `404` to avoid acting as an existence oracle. 233 234 Args: 235 file: File ID of the shared file (`fil_...`). The file must currently be marked as publicly shared. 236 token: HMAC capability token authorizing access to this specific file. Obtained from the `share_url` returned when the file was uploaded with `share: true`. 237 238 Returns: 239 Raw image bytes of the shared file, served with the file's original content type. 240 """ 241 query: dict[str, object] = {} 242 query["token"] = token 243 return await self._http.request_raw(f"/api/v1/files/{file}/share", query=query) 244 245 246class FileResource: 247 def __init__(self, http: SyncHttpClient): 248 self._http = http 249 250 def create(self, input: FileCreateInput) -> StorageFile: 251 """ 252 Upload a file 253 Creates a new file from base64-encoded content and returns the resulting file object, 254 including a signed download URL. Use this endpoint to store images, documents, or 255 other binary assets that can then be referenced by agents, teams, or users. 256 App scope is derived from the authenticated viewer's bearer token or publishable key. 257 You may optionally associate the file with an organization, team, user, or agent by 258 passing the corresponding ID. If no owner is specified and the viewer is a user, the 259 file is automatically attributed to that user. 260 Pass `share: true` to additionally mint a stable public URL for the file 261 (returned as `share_url`), fetchable by anyone without authentication for 262 example to embed an uploaded image in a GitHub PR body or other external 263 markdown. The URL does not expire. Sharing is revoked by setting 264 `share: false` on `PATCH /api/v1/files/:file` with the same credential 265 (or `archastro update file <id> --unshare`); re-enabling sharing 266 reactivates previously issued URLs. Only image content types can be 267 shared. 268 Returns `422` when the `data` field is not valid base64, the changeset is 269 invalid, or `share` is requested for a non-image content type. 270 Returns `403` when the request lacks the required app scope. 271 272 Args: 273 input: Request body. 274 input.acl: Access control list for the file. Supports explicit `read` and `write` grants to users, teams, organizations, organization roles, agents, or everyone. 275 input.agent: Agent ID (`agi_...`) to associate with this file. When provided, the file's organization is derived from the agent. 276 input.content_type: MIME type of the file, e.g. `"image/png"` or `"application/pdf"`. 277 input.data: Base64-encoded binary content of the file to upload. 278 input.filename: Original filename including extension, e.g. `"avatar.png"`. 279 input.org: Organization ID (`org_...`) to associate with this file. Optional; defaults to the viewer's organization when omitted. 280 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. 281 input.team: Team ID (`tem_...`) that owns this file. Takes precedence over `user` when both are provided. 282 input.user: User ID (`usr_...`) that owns this file. Defaults to the authenticated user when neither `user` nor `team` is specified. 283 284 Returns: 285 The newly created file, including a signed download URL. 286 """ 287 return self._http.request( 288 "/api/v1/files", 289 method="POST", 290 body=input, 291 response_type=StorageFile, 292 ) 293 294 def update(self, file: str, input: FileUpdateInput) -> StorageFile: 295 """ 296 Update a file 297 Updates mutable fields of an existing file. Only the fields you supply are 298 changed; omitted fields retain their current values. The file's stored content 299 and `content_type` cannot be changed after creation. 300 This endpoint is the companion to `share: true` on file upload: the same 301 credential that granted public sharing can revoke it here with `share: false` 302 (or grant it later with `share: true`; only image content types can be 303 shared, and re-enabling sharing reactivates any previously issued share 304 URLs). App scope is derived from the authenticated viewer, matching upload. 305 A file that exists but is not visible to the current viewer returns `404` 306 rather than `403` to avoid revealing the file's existence. 307 308 Args: 309 file: File ID (`fil_...`) of the file to update. 310 input: Request body. 311 input.filename: New name for the file, including extension, e.g. `"report_v2.pdf"`. Omit to leave the current filename unchanged. 312 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. 313 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. 314 315 Returns: 316 The updated file, including a signed download URL. 317 """ 318 return self._http.request( 319 f"/api/v1/files/{file}", 320 method="PATCH", 321 body=input, 322 response_type=StorageFile, 323 ) 324 325 def avatar(self, file: str, token: str) -> dict[str, str]: 326 """ 327 Fetch an agent avatar image 328 Returns the raw image bytes for an agent's profile picture identified by `file`. 329 This endpoint is designed for integration partners (such as Slack) that fetch 330 avatar URLs via plain GET requests without bearer token support. Authorization 331 is performed via a short, stable capability `token` rather than an HTTP header. 332 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 333 but it is invalidated when the agent's profile picture is replaced or the agent is 334 deleted shared caches may continue serving the old image until the 335 `Cache-Control` max-age of one hour elapses. The endpoint never redirects to 336 a signed storage URL; bytes are served inline so behavior is consistent across 337 storage backends. 338 All failure modes invalid file ID, invalid token, file not currently referenced 339 as an agent avatar return a uniform `404` to avoid acting as an existence oracle. 340 341 Args: 342 file: File ID of the agent's profile picture (`fil_...`). Must be currently set as an agent's profile picture within the same app. 343 token: HMAC capability token authorizing access to this specific file. Obtained from the avatar URL minted when the profile picture was set. 344 345 Returns: 346 Raw image bytes of the agent avatar, served with the file's original content type. 347 """ 348 query: dict[str, object] = {} 349 query["token"] = token 350 return self._http.request_raw(f"/api/v1/files/{file}/avatar", query=query) 351 352 def org_logo(self, file: str, token: str) -> dict[str, str]: 353 """ 354 Fetch an org logo image 355 Returns the raw image bytes for an organization's logo identified by `file`. 356 This endpoint backs the `org_logo.url` field of catalog payloads (such as 357 `GET /api/v1/solutions`), which anonymous consumers the public marketplace's 358 page cache, OpenGraph scrapers may hold far longer than a signed storage URL 359 lives. Authorization is performed via a short, stable capability `token` rather 360 than an HTTP header, so the URL never expires. 361 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 362 but it is invalidated when the org's logo is replaced or removed shared caches 363 may continue serving the old image until the `Cache-Control` max-age of one hour 364 elapses. The endpoint never redirects to a signed storage URL; bytes are served 365 inline so behavior is consistent across storage backends. 366 All failure modes invalid file ID, invalid token, file not currently referenced 367 as an org logo return a uniform `404` to avoid acting as an existence oracle. 368 369 Args: 370 file: File ID of the org's logo (`fil_...`). Must be currently set as an organization's logo within the same app. 371 token: HMAC capability token authorizing access to this specific file. Obtained from the `org_logo.url` minted when the logo was serialized. 372 373 Returns: 374 Raw image bytes of the org logo, served with the file's original content type. 375 """ 376 query: dict[str, object] = {} 377 query["token"] = token 378 return self._http.request_raw(f"/api/v1/files/{file}/org_logo", query=query) 379 380 def share(self, file: str, token: str) -> dict[str, str]: 381 """ 382 Fetch a publicly shared file 383 Returns the raw image bytes for a file that was explicitly shared for public 384 access, identified by `file`. This endpoint is designed for consumers that hold 385 a URL far longer than a signed storage URL lives GitHub PR bodies (whose camo 386 image proxy re-fetches from the origin URL), wikis, and issue trackers and 387 fetch it via plain GET requests without bearer token support. Authorization is 388 performed via a short, stable capability `token` rather than an HTTP header. 389 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 390 but it is invalidated when sharing is turned off for the file (`share: false` on 391 the file update endpoint) or the file is deleted shared caches may continue 392 serving the bytes until the `Cache-Control` max-age of one hour elapses. The 393 endpoint never redirects to a signed storage URL; bytes are served inline so 394 behavior is consistent across storage backends. Only image content types are 395 served. 396 All failure modes invalid file ID, invalid token, file not currently shared 397 return a uniform `404` to avoid acting as an existence oracle. 398 399 Args: 400 file: File ID of the shared file (`fil_...`). The file must currently be marked as publicly shared. 401 token: HMAC capability token authorizing access to this specific file. Obtained from the `share_url` returned when the file was uploaded with `share: true`. 402 403 Returns: 404 Raw image bytes of the shared file, served with the file's original content type. 405 """ 406 query: dict[str, object] = {} 407 query["token"] = token 408 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 App scope is derived from the authenticated viewer's bearer token or publishable key. 93 You may optionally associate the file with an organization, team, user, or agent by 94 passing the corresponding ID. If no owner is specified and the viewer is a user, the 95 file is automatically attributed to that user. 96 Pass `share: true` to additionally mint a stable public URL for the file 97 (returned as `share_url`), fetchable by anyone without authentication for 98 example to embed an uploaded image in a GitHub PR body or other external 99 markdown. The URL does not expire. Sharing is revoked by setting 100 `share: false` on `PATCH /api/v1/files/:file` with the same credential 101 (or `archastro update file <id> --unshare`); re-enabling sharing 102 reactivates previously issued URLs. Only image content types can be 103 shared. 104 Returns `422` when the `data` field is not valid base64, the changeset is 105 invalid, or `share` is requested for a non-image content type. 106 Returns `403` when the request lacks the required app scope. 107 108 Args: 109 input: Request body. 110 input.acl: Access control list for the file. Supports explicit `read` and `write` grants to users, teams, organizations, organization roles, agents, or everyone. 111 input.agent: Agent ID (`agi_...`) to associate with this file. When provided, the file's organization is derived from the agent. 112 input.content_type: MIME type of the file, e.g. `"image/png"` or `"application/pdf"`. 113 input.data: Base64-encoded binary content of the file to upload. 114 input.filename: Original filename including extension, e.g. `"avatar.png"`. 115 input.org: Organization ID (`org_...`) to associate with this file. Optional; defaults to the viewer's organization when omitted. 116 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. 117 input.team: Team ID (`tem_...`) that owns this file. Takes precedence over `user` when both are provided. 118 input.user: User ID (`usr_...`) that owns this file. Defaults to the authenticated user when neither `user` nor `team` is specified. 119 120 Returns: 121 The newly created file, including a signed download URL. 122 """ 123 return await self._http.request( 124 "/api/v1/files", 125 method="POST", 126 body=input, 127 response_type=StorageFile, 128 ) 129 130 async def update(self, file: str, input: FileUpdateInput) -> StorageFile: 131 """ 132 Update a file 133 Updates mutable fields of an existing file. Only the fields you supply are 134 changed; omitted fields retain their current values. The file's stored content 135 and `content_type` cannot be changed after creation. 136 This endpoint is the companion to `share: true` on file upload: the same 137 credential that granted public sharing can revoke it here with `share: false` 138 (or grant it later with `share: true`; only image content types can be 139 shared, and re-enabling sharing reactivates any previously issued share 140 URLs). App scope is derived from the authenticated viewer, matching upload. 141 A file that exists but is not visible to the current viewer returns `404` 142 rather than `403` to avoid revealing the file's existence. 143 144 Args: 145 file: File ID (`fil_...`) of the file to update. 146 input: Request body. 147 input.filename: New name for the file, including extension, e.g. `"report_v2.pdf"`. Omit to leave the current filename unchanged. 148 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. 149 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. 150 151 Returns: 152 The updated file, including a signed download URL. 153 """ 154 return await self._http.request( 155 f"/api/v1/files/{file}", 156 method="PATCH", 157 body=input, 158 response_type=StorageFile, 159 ) 160 161 async def avatar(self, file: str, token: str) -> dict[str, str]: 162 """ 163 Fetch an agent avatar image 164 Returns the raw image bytes for an agent's profile picture identified by `file`. 165 This endpoint is designed for integration partners (such as Slack) that fetch 166 avatar URLs via plain GET requests without bearer token support. Authorization 167 is performed via a short, stable capability `token` rather than an HTTP header. 168 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 169 but it is invalidated when the agent's profile picture is replaced or the agent is 170 deleted shared caches may continue serving the old image until the 171 `Cache-Control` max-age of one hour elapses. The endpoint never redirects to 172 a signed storage URL; bytes are served inline so behavior is consistent across 173 storage backends. 174 All failure modes invalid file ID, invalid token, file not currently referenced 175 as an agent avatar return a uniform `404` to avoid acting as an existence oracle. 176 177 Args: 178 file: File ID of the agent's profile picture (`fil_...`). Must be currently set as an agent's profile picture within the same app. 179 token: HMAC capability token authorizing access to this specific file. Obtained from the avatar URL minted when the profile picture was set. 180 181 Returns: 182 Raw image bytes of the agent avatar, served with the file's original content type. 183 """ 184 query: dict[str, object] = {} 185 query["token"] = token 186 return await self._http.request_raw(f"/api/v1/files/{file}/avatar", query=query) 187 188 async def org_logo(self, file: str, token: str) -> dict[str, str]: 189 """ 190 Fetch an org logo image 191 Returns the raw image bytes for an organization's logo identified by `file`. 192 This endpoint backs the `org_logo.url` field of catalog payloads (such as 193 `GET /api/v1/solutions`), which anonymous consumers the public marketplace's 194 page cache, OpenGraph scrapers may hold far longer than a signed storage URL 195 lives. Authorization is performed via a short, stable capability `token` rather 196 than an HTTP header, so the URL never expires. 197 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 198 but it is invalidated when the org's logo is replaced or removed shared caches 199 may continue serving the old image until the `Cache-Control` max-age of one hour 200 elapses. The endpoint never redirects to a signed storage URL; bytes are served 201 inline so behavior is consistent across storage backends. 202 All failure modes invalid file ID, invalid token, file not currently referenced 203 as an org logo return a uniform `404` to avoid acting as an existence oracle. 204 205 Args: 206 file: File ID of the org's logo (`fil_...`). Must be currently set as an organization's logo within the same app. 207 token: HMAC capability token authorizing access to this specific file. Obtained from the `org_logo.url` minted when the logo was serialized. 208 209 Returns: 210 Raw image bytes of the org logo, served with the file's original content type. 211 """ 212 query: dict[str, object] = {} 213 query["token"] = token 214 return await self._http.request_raw(f"/api/v1/files/{file}/org_logo", query=query) 215 216 async def share(self, file: str, token: str) -> dict[str, str]: 217 """ 218 Fetch a publicly shared file 219 Returns the raw image bytes for a file that was explicitly shared for public 220 access, identified by `file`. This endpoint is designed for consumers that hold 221 a URL far longer than a signed storage URL lives GitHub PR bodies (whose camo 222 image proxy re-fetches from the origin URL), wikis, and issue trackers and 223 fetch it via plain GET requests without bearer token support. Authorization is 224 performed via a short, stable capability `token` rather than an HTTP header. 225 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 226 but it is invalidated when sharing is turned off for the file (`share: false` on 227 the file update endpoint) or the file is deleted shared caches may continue 228 serving the bytes until the `Cache-Control` max-age of one hour elapses. The 229 endpoint never redirects to a signed storage URL; bytes are served inline so 230 behavior is consistent across storage backends. Only image content types are 231 served. 232 All failure modes invalid file ID, invalid token, file not currently shared 233 return a uniform `404` to avoid acting as an existence oracle. 234 235 Args: 236 file: File ID of the shared file (`fil_...`). The file must currently be marked as publicly shared. 237 token: HMAC capability token authorizing access to this specific file. Obtained from the `share_url` returned when the file was uploaded with `share: true`. 238 239 Returns: 240 Raw image bytes of the shared file, served with the file's original content type. 241 """ 242 query: dict[str, object] = {} 243 query["token"] = token 244 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 App scope is derived from the authenticated viewer's bearer token or publishable key. 93 You may optionally associate the file with an organization, team, user, or agent by 94 passing the corresponding ID. If no owner is specified and the viewer is a user, the 95 file is automatically attributed to that user. 96 Pass `share: true` to additionally mint a stable public URL for the file 97 (returned as `share_url`), fetchable by anyone without authentication for 98 example to embed an uploaded image in a GitHub PR body or other external 99 markdown. The URL does not expire. Sharing is revoked by setting 100 `share: false` on `PATCH /api/v1/files/:file` with the same credential 101 (or `archastro update file <id> --unshare`); re-enabling sharing 102 reactivates previously issued URLs. Only image content types can be 103 shared. 104 Returns `422` when the `data` field is not valid base64, the changeset is 105 invalid, or `share` is requested for a non-image content type. 106 Returns `403` when the request lacks the required app scope. 107 108 Args: 109 input: Request body. 110 input.acl: Access control list for the file. Supports explicit `read` and `write` grants to users, teams, organizations, organization roles, agents, or everyone. 111 input.agent: Agent ID (`agi_...`) to associate with this file. When provided, the file's organization is derived from the agent. 112 input.content_type: MIME type of the file, e.g. `"image/png"` or `"application/pdf"`. 113 input.data: Base64-encoded binary content of the file to upload. 114 input.filename: Original filename including extension, e.g. `"avatar.png"`. 115 input.org: Organization ID (`org_...`) to associate with this file. Optional; defaults to the viewer's organization when omitted. 116 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. 117 input.team: Team ID (`tem_...`) that owns this file. Takes precedence over `user` when both are provided. 118 input.user: User ID (`usr_...`) that owns this file. Defaults to the authenticated user when neither `user` nor `team` is specified. 119 120 Returns: 121 The newly created file, including a signed download URL. 122 """ 123 return await self._http.request( 124 "/api/v1/files", 125 method="POST", 126 body=input, 127 response_type=StorageFile, 128 )
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.
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.
130 async def update(self, file: str, input: FileUpdateInput) -> StorageFile: 131 """ 132 Update a file 133 Updates mutable fields of an existing file. Only the fields you supply are 134 changed; omitted fields retain their current values. The file's stored content 135 and `content_type` cannot be changed after creation. 136 This endpoint is the companion to `share: true` on file upload: the same 137 credential that granted public sharing can revoke it here with `share: false` 138 (or grant it later with `share: true`; only image content types can be 139 shared, and re-enabling sharing reactivates any previously issued share 140 URLs). App scope is derived from the authenticated viewer, matching upload. 141 A file that exists but is not visible to the current viewer returns `404` 142 rather than `403` to avoid revealing the file's existence. 143 144 Args: 145 file: File ID (`fil_...`) of the file to update. 146 input: Request body. 147 input.filename: New name for the file, including extension, e.g. `"report_v2.pdf"`. Omit to leave the current filename unchanged. 148 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. 149 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. 150 151 Returns: 152 The updated file, including a signed download URL. 153 """ 154 return await self._http.request( 155 f"/api/v1/files/{file}", 156 method="PATCH", 157 body=input, 158 response_type=StorageFile, 159 )
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.
161 async def avatar(self, file: str, token: str) -> dict[str, str]: 162 """ 163 Fetch an agent avatar image 164 Returns the raw image bytes for an agent's profile picture identified by `file`. 165 This endpoint is designed for integration partners (such as Slack) that fetch 166 avatar URLs via plain GET requests without bearer token support. Authorization 167 is performed via a short, stable capability `token` rather than an HTTP header. 168 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 169 but it is invalidated when the agent's profile picture is replaced or the agent is 170 deleted shared caches may continue serving the old image until the 171 `Cache-Control` max-age of one hour elapses. The endpoint never redirects to 172 a signed storage URL; bytes are served inline so behavior is consistent across 173 storage backends. 174 All failure modes invalid file ID, invalid token, file not currently referenced 175 as an agent avatar return a uniform `404` to avoid acting as an existence oracle. 176 177 Args: 178 file: File ID of the agent's profile picture (`fil_...`). Must be currently set as an agent's profile picture within the same app. 179 token: HMAC capability token authorizing access to this specific file. Obtained from the avatar URL minted when the profile picture was set. 180 181 Returns: 182 Raw image bytes of the agent avatar, served with the file's original content type. 183 """ 184 query: dict[str, object] = {} 185 query["token"] = token 186 return await self._http.request_raw(f"/api/v1/files/{file}/avatar", query=query)
Fetch an agent avatar image
Returns the raw image bytes for an agent's profile picture identified by file.
This endpoint is designed for integration partners (such as Slack) that fetch
avatar URLs via plain GET requests without bearer token support. 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 agent's profile picture is replaced or the agent 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 agent's profile picture (
fil_...). Must be currently set as an agent'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 agent avatar, served with the file's original content type.
188 async def org_logo(self, file: str, token: str) -> dict[str, str]: 189 """ 190 Fetch an org logo image 191 Returns the raw image bytes for an organization's logo identified by `file`. 192 This endpoint backs the `org_logo.url` field of catalog payloads (such as 193 `GET /api/v1/solutions`), which anonymous consumers the public marketplace's 194 page cache, OpenGraph scrapers may hold far longer than a signed storage URL 195 lives. Authorization is performed via a short, stable capability `token` rather 196 than an HTTP header, so the URL never expires. 197 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 198 but it is invalidated when the org's logo is replaced or removed shared caches 199 may continue serving the old image until the `Cache-Control` max-age of one hour 200 elapses. The endpoint never redirects to a signed storage URL; bytes are served 201 inline so behavior is consistent across storage backends. 202 All failure modes invalid file ID, invalid token, file not currently referenced 203 as an org logo return a uniform `404` to avoid acting as an existence oracle. 204 205 Args: 206 file: File ID of the org's logo (`fil_...`). Must be currently set as an organization's logo within the same app. 207 token: HMAC capability token authorizing access to this specific file. Obtained from the `org_logo.url` minted when the logo was serialized. 208 209 Returns: 210 Raw image bytes of the org logo, served with the file's original content type. 211 """ 212 query: dict[str, object] = {} 213 query["token"] = token 214 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.
247class FileResource: 248 def __init__(self, http: SyncHttpClient): 249 self._http = http 250 251 def create(self, input: FileCreateInput) -> StorageFile: 252 """ 253 Upload a file 254 Creates a new file from base64-encoded content and returns the resulting file object, 255 including a signed download URL. Use this endpoint to store images, documents, or 256 other binary assets that can then be referenced by agents, teams, or users. 257 App scope is derived from the authenticated viewer's bearer token or publishable key. 258 You may optionally associate the file with an organization, team, user, or agent by 259 passing the corresponding ID. If no owner is specified and the viewer is a user, the 260 file is automatically attributed to that user. 261 Pass `share: true` to additionally mint a stable public URL for the file 262 (returned as `share_url`), fetchable by anyone without authentication for 263 example to embed an uploaded image in a GitHub PR body or other external 264 markdown. The URL does not expire. Sharing is revoked by setting 265 `share: false` on `PATCH /api/v1/files/:file` with the same credential 266 (or `archastro update file <id> --unshare`); re-enabling sharing 267 reactivates previously issued URLs. Only image content types can be 268 shared. 269 Returns `422` when the `data` field is not valid base64, the changeset is 270 invalid, or `share` is requested for a non-image content type. 271 Returns `403` when the request lacks the required app scope. 272 273 Args: 274 input: Request body. 275 input.acl: Access control list for the file. Supports explicit `read` and `write` grants to users, teams, organizations, organization roles, agents, or everyone. 276 input.agent: Agent ID (`agi_...`) to associate with this file. When provided, the file's organization is derived from the agent. 277 input.content_type: MIME type of the file, e.g. `"image/png"` or `"application/pdf"`. 278 input.data: Base64-encoded binary content of the file to upload. 279 input.filename: Original filename including extension, e.g. `"avatar.png"`. 280 input.org: Organization ID (`org_...`) to associate with this file. Optional; defaults to the viewer's organization when omitted. 281 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. 282 input.team: Team ID (`tem_...`) that owns this file. Takes precedence over `user` when both are provided. 283 input.user: User ID (`usr_...`) that owns this file. Defaults to the authenticated user when neither `user` nor `team` is specified. 284 285 Returns: 286 The newly created file, including a signed download URL. 287 """ 288 return self._http.request( 289 "/api/v1/files", 290 method="POST", 291 body=input, 292 response_type=StorageFile, 293 ) 294 295 def update(self, file: str, input: FileUpdateInput) -> StorageFile: 296 """ 297 Update a file 298 Updates mutable fields of an existing file. Only the fields you supply are 299 changed; omitted fields retain their current values. The file's stored content 300 and `content_type` cannot be changed after creation. 301 This endpoint is the companion to `share: true` on file upload: the same 302 credential that granted public sharing can revoke it here with `share: false` 303 (or grant it later with `share: true`; only image content types can be 304 shared, and re-enabling sharing reactivates any previously issued share 305 URLs). App scope is derived from the authenticated viewer, matching upload. 306 A file that exists but is not visible to the current viewer returns `404` 307 rather than `403` to avoid revealing the file's existence. 308 309 Args: 310 file: File ID (`fil_...`) of the file to update. 311 input: Request body. 312 input.filename: New name for the file, including extension, e.g. `"report_v2.pdf"`. Omit to leave the current filename unchanged. 313 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. 314 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. 315 316 Returns: 317 The updated file, including a signed download URL. 318 """ 319 return self._http.request( 320 f"/api/v1/files/{file}", 321 method="PATCH", 322 body=input, 323 response_type=StorageFile, 324 ) 325 326 def avatar(self, file: str, token: str) -> dict[str, str]: 327 """ 328 Fetch an agent avatar image 329 Returns the raw image bytes for an agent's profile picture identified by `file`. 330 This endpoint is designed for integration partners (such as Slack) that fetch 331 avatar URLs via plain GET requests without bearer token support. Authorization 332 is performed via a short, stable capability `token` rather than an HTTP header. 333 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 334 but it is invalidated when the agent's profile picture is replaced or the agent is 335 deleted shared caches may continue serving the old image until the 336 `Cache-Control` max-age of one hour elapses. The endpoint never redirects to 337 a signed storage URL; bytes are served inline so behavior is consistent across 338 storage backends. 339 All failure modes invalid file ID, invalid token, file not currently referenced 340 as an agent avatar return a uniform `404` to avoid acting as an existence oracle. 341 342 Args: 343 file: File ID of the agent's profile picture (`fil_...`). Must be currently set as an agent's profile picture within the same app. 344 token: HMAC capability token authorizing access to this specific file. Obtained from the avatar URL minted when the profile picture was set. 345 346 Returns: 347 Raw image bytes of the agent avatar, served with the file's original content type. 348 """ 349 query: dict[str, object] = {} 350 query["token"] = token 351 return self._http.request_raw(f"/api/v1/files/{file}/avatar", query=query) 352 353 def org_logo(self, file: str, token: str) -> dict[str, str]: 354 """ 355 Fetch an org logo image 356 Returns the raw image bytes for an organization's logo identified by `file`. 357 This endpoint backs the `org_logo.url` field of catalog payloads (such as 358 `GET /api/v1/solutions`), which anonymous consumers the public marketplace's 359 page cache, OpenGraph scrapers may hold far longer than a signed storage URL 360 lives. Authorization is performed via a short, stable capability `token` rather 361 than an HTTP header, so the URL never expires. 362 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 363 but it is invalidated when the org's logo is replaced or removed shared caches 364 may continue serving the old image until the `Cache-Control` max-age of one hour 365 elapses. The endpoint never redirects to a signed storage URL; bytes are served 366 inline so behavior is consistent across storage backends. 367 All failure modes invalid file ID, invalid token, file not currently referenced 368 as an org logo return a uniform `404` to avoid acting as an existence oracle. 369 370 Args: 371 file: File ID of the org's logo (`fil_...`). Must be currently set as an organization's logo within the same app. 372 token: HMAC capability token authorizing access to this specific file. Obtained from the `org_logo.url` minted when the logo was serialized. 373 374 Returns: 375 Raw image bytes of the org logo, served with the file's original content type. 376 """ 377 query: dict[str, object] = {} 378 query["token"] = token 379 return self._http.request_raw(f"/api/v1/files/{file}/org_logo", query=query) 380 381 def share(self, file: str, token: str) -> dict[str, str]: 382 """ 383 Fetch a publicly shared file 384 Returns the raw image bytes for a file that was explicitly shared for public 385 access, identified by `file`. This endpoint is designed for consumers that hold 386 a URL far longer than a signed storage URL lives GitHub PR bodies (whose camo 387 image proxy re-fetches from the origin URL), wikis, and issue trackers and 388 fetch it via plain GET requests without bearer token support. Authorization is 389 performed via a short, stable capability `token` rather than an HTTP header. 390 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 391 but it is invalidated when sharing is turned off for the file (`share: false` on 392 the file update endpoint) or the file is deleted shared caches may continue 393 serving the bytes until the `Cache-Control` max-age of one hour elapses. The 394 endpoint never redirects to a signed storage URL; bytes are served inline so 395 behavior is consistent across storage backends. Only image content types are 396 served. 397 All failure modes invalid file ID, invalid token, file not currently shared 398 return a uniform `404` to avoid acting as an existence oracle. 399 400 Args: 401 file: File ID of the shared file (`fil_...`). The file must currently be marked as publicly shared. 402 token: HMAC capability token authorizing access to this specific file. Obtained from the `share_url` returned when the file was uploaded with `share: true`. 403 404 Returns: 405 Raw image bytes of the shared file, served with the file's original content type. 406 """ 407 query: dict[str, object] = {} 408 query["token"] = token 409 return self._http.request_raw(f"/api/v1/files/{file}/share", query=query)
251 def create(self, input: FileCreateInput) -> StorageFile: 252 """ 253 Upload a file 254 Creates a new file from base64-encoded content and returns the resulting file object, 255 including a signed download URL. Use this endpoint to store images, documents, or 256 other binary assets that can then be referenced by agents, teams, or users. 257 App scope is derived from the authenticated viewer's bearer token or publishable key. 258 You may optionally associate the file with an organization, team, user, or agent by 259 passing the corresponding ID. If no owner is specified and the viewer is a user, the 260 file is automatically attributed to that user. 261 Pass `share: true` to additionally mint a stable public URL for the file 262 (returned as `share_url`), fetchable by anyone without authentication for 263 example to embed an uploaded image in a GitHub PR body or other external 264 markdown. The URL does not expire. Sharing is revoked by setting 265 `share: false` on `PATCH /api/v1/files/:file` with the same credential 266 (or `archastro update file <id> --unshare`); re-enabling sharing 267 reactivates previously issued URLs. Only image content types can be 268 shared. 269 Returns `422` when the `data` field is not valid base64, the changeset is 270 invalid, or `share` is requested for a non-image content type. 271 Returns `403` when the request lacks the required app scope. 272 273 Args: 274 input: Request body. 275 input.acl: Access control list for the file. Supports explicit `read` and `write` grants to users, teams, organizations, organization roles, agents, or everyone. 276 input.agent: Agent ID (`agi_...`) to associate with this file. When provided, the file's organization is derived from the agent. 277 input.content_type: MIME type of the file, e.g. `"image/png"` or `"application/pdf"`. 278 input.data: Base64-encoded binary content of the file to upload. 279 input.filename: Original filename including extension, e.g. `"avatar.png"`. 280 input.org: Organization ID (`org_...`) to associate with this file. Optional; defaults to the viewer's organization when omitted. 281 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. 282 input.team: Team ID (`tem_...`) that owns this file. Takes precedence over `user` when both are provided. 283 input.user: User ID (`usr_...`) that owns this file. Defaults to the authenticated user when neither `user` nor `team` is specified. 284 285 Returns: 286 The newly created file, including a signed download URL. 287 """ 288 return self._http.request( 289 "/api/v1/files", 290 method="POST", 291 body=input, 292 response_type=StorageFile, 293 )
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.
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.
295 def update(self, file: str, input: FileUpdateInput) -> StorageFile: 296 """ 297 Update a file 298 Updates mutable fields of an existing file. Only the fields you supply are 299 changed; omitted fields retain their current values. The file's stored content 300 and `content_type` cannot be changed after creation. 301 This endpoint is the companion to `share: true` on file upload: the same 302 credential that granted public sharing can revoke it here with `share: false` 303 (or grant it later with `share: true`; only image content types can be 304 shared, and re-enabling sharing reactivates any previously issued share 305 URLs). App scope is derived from the authenticated viewer, matching upload. 306 A file that exists but is not visible to the current viewer returns `404` 307 rather than `403` to avoid revealing the file's existence. 308 309 Args: 310 file: File ID (`fil_...`) of the file to update. 311 input: Request body. 312 input.filename: New name for the file, including extension, e.g. `"report_v2.pdf"`. Omit to leave the current filename unchanged. 313 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. 314 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. 315 316 Returns: 317 The updated file, including a signed download URL. 318 """ 319 return self._http.request( 320 f"/api/v1/files/{file}", 321 method="PATCH", 322 body=input, 323 response_type=StorageFile, 324 )
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.
326 def avatar(self, file: str, token: str) -> dict[str, str]: 327 """ 328 Fetch an agent avatar image 329 Returns the raw image bytes for an agent's profile picture identified by `file`. 330 This endpoint is designed for integration partners (such as Slack) that fetch 331 avatar URLs via plain GET requests without bearer token support. Authorization 332 is performed via a short, stable capability `token` rather than an HTTP header. 333 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 334 but it is invalidated when the agent's profile picture is replaced or the agent is 335 deleted shared caches may continue serving the old image until the 336 `Cache-Control` max-age of one hour elapses. The endpoint never redirects to 337 a signed storage URL; bytes are served inline so behavior is consistent across 338 storage backends. 339 All failure modes invalid file ID, invalid token, file not currently referenced 340 as an agent avatar return a uniform `404` to avoid acting as an existence oracle. 341 342 Args: 343 file: File ID of the agent's profile picture (`fil_...`). Must be currently set as an agent's profile picture within the same app. 344 token: HMAC capability token authorizing access to this specific file. Obtained from the avatar URL minted when the profile picture was set. 345 346 Returns: 347 Raw image bytes of the agent avatar, served with the file's original content type. 348 """ 349 query: dict[str, object] = {} 350 query["token"] = token 351 return self._http.request_raw(f"/api/v1/files/{file}/avatar", query=query)
Fetch an agent avatar image
Returns the raw image bytes for an agent's profile picture identified by file.
This endpoint is designed for integration partners (such as Slack) that fetch
avatar URLs via plain GET requests without bearer token support. 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 agent's profile picture is replaced or the agent 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 agent's profile picture (
fil_...). Must be currently set as an agent'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 agent avatar, served with the file's original content type.
353 def org_logo(self, file: str, token: str) -> dict[str, str]: 354 """ 355 Fetch an org logo image 356 Returns the raw image bytes for an organization's logo identified by `file`. 357 This endpoint backs the `org_logo.url` field of catalog payloads (such as 358 `GET /api/v1/solutions`), which anonymous consumers the public marketplace's 359 page cache, OpenGraph scrapers may hold far longer than a signed storage URL 360 lives. Authorization is performed via a short, stable capability `token` rather 361 than an HTTP header, so the URL never expires. 362 The `token` is an HMAC-based capability tied to the file ID. It does not expire, 363 but it is invalidated when the org's logo is replaced or removed shared caches 364 may continue serving the old image until the `Cache-Control` max-age of one hour 365 elapses. The endpoint never redirects to a signed storage URL; bytes are served 366 inline so behavior is consistent across storage backends. 367 All failure modes invalid file ID, invalid token, file not currently referenced 368 as an org logo return a uniform `404` to avoid acting as an existence oracle. 369 370 Args: 371 file: File ID of the org's logo (`fil_...`). Must be currently set as an organization's logo within the same app. 372 token: HMAC capability token authorizing access to this specific file. Obtained from the `org_logo.url` minted when the logo was serialized. 373 374 Returns: 375 Raw image bytes of the org logo, served with the file's original content type. 376 """ 377 query: dict[str, object] = {} 378 query["token"] = token 379 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.