@archastro/sdk
    Preparing search index...
    Index

    Constructors

    Methods

    • Create a custom object Creates a new custom object of the given schema type and returns the persisted object. The caller must be authenticated and authorized to create objects of the specified type. Identify the schema with type (preferred), or the legacy aliases schema_key (lookup key) / config (config ID). Exactly one identifier is required; when more than one is supplied, type wins over schema_key, which wins over config. Owner resolution follows a priority order: if team is supplied the object is team-owned; if user is supplied it is owned by that user; if agent is supplied it is agent-owned; otherwise the object is owned by the authenticated user. Pass system: true explicitly to force system ownership — this requires elevated API credentials and returns 403 if the caller lacks permission. If the schema declares a row_key (and optionally a sort_key), you may pass upsert: true to update an existing object at that key instead of receiving a 409 Conflict. The response status is 200 on an update and 201 on a new create.

      Parameters

      • input: {
            acl?: {
                add?: { actions: string[]; principal?: string; principal_type: string }[];
                add_denies?: {
                    actions: string[];
                    principal?: string;
                    principal_type: string;
                }[];
                denies?: { actions: string[]; principal?: string; principal_type: string }[];
                grants?: { actions: string[]; principal?: string; principal_type: string }[];
                preserve_denies?: boolean;
                remove?: { principal?: string; principal_type: string }[];
                remove_denies?: { principal?: string; principal_type: string }[];
            };
            agent?: string;
            config?: string;
            expires_at?: string
            | null;
            fields?: Record<string, unknown>;
            org?: string;
            schema_key?: string;
            system?: boolean;
            team?: string;
            type?: string;
            upsert?: boolean;
            user?: string;
        }

        Request body.

        • Optionalacl?: {
              add?: { actions: string[]; principal?: string; principal_type: string }[];
              add_denies?: {
                  actions: string[];
                  principal?: string;
                  principal_type: string;
              }[];
              denies?: { actions: string[]; principal?: string; principal_type: string }[];
              grants?: { actions: string[]; principal?: string; principal_type: string }[];
              preserve_denies?: boolean;
              remove?: { principal?: string; principal_type: string }[];
              remove_denies?: { principal?: string; principal_type: string }[];
          }

          Access control list for the custom object. Supports explicit read and write grants to users, teams, organizations, organization roles, agents, or everyone.

        • Optionalagent?: string

          Agent user ID to set as the object owner. Used when neither team nor user is supplied.

        • Optionalconfig?: string

          Config ID (cfg_...) that resolves to the target schema. Provide one of type, schema_key, or config.

        • Optionalexpires_at?: string | null

          Absolute expiry time in RFC 3339 format. Pass null to clear; omit to leave unchanged on update.

        • Optionalfields?: Record<string, unknown>

          Key-value map of field values for the new object. Must conform to the schema's field definitions. Omit to create an object with all fields at their default or null values.

        • Optionalorg?: string

          Organization ID (org_...) to associate with the object. Typically required for system-owned objects.

        • Optionalschema_key?: string

          Legacy alias for type (schema lookup_key). Prefer type on new clients. Provide one of type, schema_key, or config.

        • Optionalsystem?: boolean

          When true, creates a system-owned object with no team, user, or agent owner. Requires elevated API credentials; returns 403 if the caller lacks permission.

        • Optionalteam?: string

          Team ID (team_...) to set as the object owner. When supplied, takes priority over user and agent.

        • Optionaltype?: string

          Schema type identifier (lookup_key) that defines the object's shape and validation rules. Preferred over the legacy schema_key / config aliases.

        • Optionalupsert?: boolean

          When true and the schema declares a row_key, updates the existing object at that key for the same owner instead of returning 409 Conflict. Returns HTTP 200 on update and 201 on create.

        • Optionaluser?: string

          User ID (user_...) to set as the object owner. Used when neither team nor a higher-priority owner is set.

      Returns Promise<CustomObject>

      The created (or upserted) custom object.

    • Delete a custom object Permanently deletes the custom object identified by object. The caller must be authenticated and have permission to delete the object. On success, returns a confirmation payload containing the deleted object's ID so callers can confirm the deletion without a follow-up fetch. Attempting to delete an object that does not exist or has already been deleted returns 404.

      Parameters

      • object: string

        Custom object ID (cobj_...) of the object to delete.

      Returns Promise<{ deleted: boolean; id: string }>

      Successful response

    • Retrieve a custom object Returns a single custom object identified by its ID. The authenticated viewer must have visibility access to the object. Returns 404 if the object does not exist, has been deleted, or is not visible to the viewer.

      Parameters

      • object: string

        Custom object ID (cobj_...) to retrieve.

      • Optionalparams: { type?: string }

        Query parameters.

        • Optionaltype?: string

          Schema type identifier (lookup_key) of the object. Optional; used for routing context only.

      Returns Promise<CustomObject>

      The requested custom object.

    • List custom objects Returns a paginated list of custom objects visible to the authenticated viewer, ordered by creation time descending. Results span all ownership types (team-owned, user-owned, agent-owned, and system-owned) that the viewer has access to. Filter by schema type with type (preferred) or the legacy alias schema_key. Use the row_key param to perform an exact-match partition lookup. You may additionally supply sort_key to narrow within that partition — sort_key requires row_key and the request returns 400 if sort_key is provided alone. Owner filters (team, user, agent, org) are additive: each accepts an array of IDs (or a single ID, which is wrapped) and returns objects matching any of the supplied values. When query is supplied, results are ranked by full-text relevance (descending ts_rank) rather than creation time. The legacy search param performs a case-insensitive substring match and is retained for developer-namespace clients.

      Parameters

      • Optionalparams: {
            agent?: string[];
            fieldFilters?: Record<string, unknown>;
            includeCount?: boolean;
            keys?: Record<string, unknown>[];
            orderByField?: string;
            org?: string[];
            page?: number;
            pageSize?: number;
            query?: string;
            rowKey?: string;
            schemaKey?: string;
            search?: string;
            sortKey?: string[];
            systemOnly?: boolean;
            team?: string[];
            type?: string;
            updatedSince?: string;
            user?: string[];
        }

        Query parameters.

        • Optionalagent?: string[]

          One or more agent IDs to filter by owning agent. Returns objects owned by any of the supplied agents.

        • OptionalfieldFilters?: Record<string, unknown>

          JSON containment predicates on fields, applied before pagination and counting.

        • OptionalincludeCount?: boolean

          Include total_entries and total_pages (default true). When false, totals are null, has_next uses one extra row, and pages beyond the end return an empty list without clamping. The page offset must fit PostgreSQL's signed 64-bit integer range.

        • Optionalkeys?: Record<string, unknown>[]

          JSON-encoded array of up to 100 objects with required string row_key and optional string-array sort_key. Missing or empty sort_key selects the whole partition. Mutually exclusive with row_key and sort_key. Pagination applies globally across all matched partitions.

        • OptionalorderByField?: string

          Top-level JSON field for descending text order, with ID tie-breaker. Full-text relevance takes precedence.

        • Optionalorg?: string[]

          One or more organization IDs (org_...) to filter by. Typically used by admins to query system-owned objects in a specific org.

        • Optionalpage?: number

          Page number to retrieve (1-indexed). Defaults to 1.

        • OptionalpageSize?: number

          Number of objects per page. Defaults to 25; maximum is 100.

        • Optionalquery?: string

          Full-text search string matched against the schema's configured search fields. When supplied, results are ordered by relevance score descending instead of creation time descending.

        • OptionalrowKey?: string

          Exact row_key value to match. When supplied, only objects with this partition key are returned.

        • OptionalschemaKey?: string

          Legacy alias for type. Prefer type on new clients. When both are supplied, type wins.

        • Optionalsearch?: string

          Case-insensitive substring search applied across the schema type and serialized field values. Deprecated — prefer query for full-text search. Retained for developer-namespace clients.

        • OptionalsortKey?: string[]

          One or more sort_key values to match within the row_key partition. Requires row_key to be set.

        • OptionalsystemOnly?: boolean

          Only system-owned objects (no user, team, agent or thread owner). Visibility is unchanged.

        • Optionalteam?: string[]

          One or more team IDs (team_...) to filter by owning team. Returns objects owned by any of the supplied teams.

        • Optionaltype?: string

          Schema type identifier (lookup_key) to filter by. Only objects of this type are returned. Alias of schema_key; either name is accepted.

        • OptionalupdatedSince?: string

          Include only objects updated at or after this ISO 8601 timestamp. Applies before pagination and counting.

        • Optionaluser?: string[]

          One or more user IDs (user_...) to filter by owning user. Returns objects owned by any of the supplied users.

      Returns Promise<CustomObjectListResponse>

      Paginated list of custom objects matching the supplied filters.

    • Apply numeric patch ops to a custom object Applies numeric patch ops (increment, max, min, set_if_newer with dotted paths) atomically to a custom object and returns the updated object along with per-op results. The authenticated viewer must have permission to modify the object. Address the row in one of two ways: by object ID (cobj_...), or by schema + row_key (with optional sort_key for schemas that declare one). The keyed form resolves the row for the same owner the create contract would use and, when no row exists yet, creates it from create_with merged over the key fields before applying the ops — so an aggregator's first call creates the counter and later calls increment it. A racing create resolves to the same row instead of a duplicate. Pass idempotency_key to make retries safe: a retry with the same key and ops replays the stored result without re-applying the write (survives server restarts); reusing a key with different ops returns 409.

      Parameters

      • input: {
            agent?: string;
            create_with?: Record<string, unknown>;
            idempotency_key?: string;
            object?: string;
            ops: Record<string, unknown>[];
            row_key?: string;
            schema?: string;
            sort_key?: string[];
            team?: string;
            user?: string;
        }

        Request body.

        • Optionalagent?: string

          Agent user ID owning the keyed row. At most one owner selector may be present.

        • Optionalcreate_with?: Record<string, unknown>

          Field values used to create the row when the keyed form finds no existing row. Merged over the key fields before validation; ignored by the object form.

        • Optionalidempotency_key?: string

          Client-supplied deduplication key for this patch. A retry with the same key and the same ops replays the stored result without re-applying the write (survives server restarts); reusing a key with different ops returns 409.

        • Optionalobject?: string

          Custom object ID (cobj_...) to patch. Exactly one of object or schema + row_key is required.

        • ops: Record<string, unknown>[]

          Numeric patch ops to apply in order (e.g. [%{"op" => "increment", "path" => "count", "by" => 1}]). Supported ops: increment (by), max/min (value), set_if_newer (value, fence_path, fence).

        • Optionalrow_key?: string

          Row key naming the row within schema (e.g. a counter name). Requires schema.

        • Optionalschema?: string

          Schema type identifier (lookup_key) for the keyed form. Requires row_key.

        • Optionalsort_key?: string[]

          Sort-key segments partitioning rows within the row_key bucket. Only meaningful for schemas that declare a sort_key.

        • Optionalteam?: string

          Team ID (tem_...) owning the keyed row. Defaults to the viewer's owner like the create contract.

        • Optionaluser?: string

          User ID (usr_...) owning the keyed row. At most one owner selector may be present.

      Returns Promise<
          {
              data: {
                  acl?: {
                      add?: {
                          actions: string[];
                          principal?: string;
                          principal_type: string;
                      }[];
                      add_denies?: {
                          actions: string[];
                          principal?: string;
                          principal_type: string;
                      }[];
                      denies?: {
                          actions: string[];
                          principal?: string;
                          principal_type: string;
                      }[];
                      grants?: {
                          actions: string[];
                          principal?: string;
                          principal_type: string;
                      }[];
                      preserve_denies?: boolean;
                      remove?: { principal?: string; principal_type: string }[];
                      remove_denies?: { principal?: string; principal_type: string }[];
                  };
                  agent?: string;
                  created_at?: string;
                  expires_at?: string
                  | null;
                  fields?: Record<string, unknown>;
                  id: string;
                  org?: string;
                  row_key?: string;
                  sandbox?: string;
                  schema_type?: string;
                  team?: string;
                  updated_at?: string;
                  user?: string;
                  version?: number;
              };
              meta?: Record<string, unknown>;
          },
      >

      Successful response

    • Update a custom object Updates the fields of an existing custom object and returns the updated object along with its new version number. The authenticated viewer must have permission to modify the object. You may supply fields (a full or partial key-value map to merge into the object), field_ops (granular array operations per field), acl, or any compatible combination. The same field name must not appear in both fields and field_ops, which returns 422. Returns 404 if the object does not exist or has been deleted. Use expected_version for optimistic concurrency: if the object's current aggregate_version does not match, the request returns 409 and does not retry the caller write. Omit it to keep the existing OCC merge retry.

      Parameters

      • object: string

        Custom object ID (cobj_...) to update.

      • input: {
            acl?: {
                add?: { actions: string[]; principal?: string; principal_type: string }[];
                add_denies?: {
                    actions: string[];
                    principal?: string;
                    principal_type: string;
                }[];
                denies?: { actions: string[]; principal?: string; principal_type: string }[];
                grants?: { actions: string[]; principal?: string; principal_type: string }[];
                preserve_denies?: boolean;
                remove?: { principal?: string; principal_type: string }[];
                remove_denies?: { principal?: string; principal_type: string }[];
            };
            expected_version?: number;
            expires_at?: string
            | null;
            field_ops?: Record<string, unknown>;
            fields?: Record<string, unknown>;
            idempotency_key?: string;
            type?: string;
        }

        Request body.

        • Optionalacl?: {
              add?: { actions: string[]; principal?: string; principal_type: string }[];
              add_denies?: {
                  actions: string[];
                  principal?: string;
                  principal_type: string;
              }[];
              denies?: { actions: string[]; principal?: string; principal_type: string }[];
              grants?: { actions: string[]; principal?: string; principal_type: string }[];
              preserve_denies?: boolean;
              remove?: { principal?: string; principal_type: string }[];
              remove_denies?: { principal?: string; principal_type: string }[];
          }

          Updated access control list. Supports full replacement via grants or targeted add/remove operations.

        • Optionalexpected_version?: number

          Version number the caller expects to be current. If the object's actual current version does not match, the request returns 409 to signal a concurrent modification. Omit to skip optimistic locking and keep the existing OCC merge retry.

        • Optionalexpires_at?: string | null

          Absolute expiry time in RFC 3339 format. Pass null to clear; omit to leave unchanged on update.

        • Optionalfield_ops?: Record<string, unknown>

          Granular array operations to apply per field (e.g. append, prepend, remove). A field must not appear in both fields and field_ops.

        • Optionalfields?: Record<string, unknown>

          Key-value map of field values to merge into the object. Only the supplied keys are affected.

        • Optionalidempotency_key?: string

          Client-supplied deduplication key for this write. A retry with the same key and the same body replays the stored result without re-applying the write (survives server restarts); reusing a key with a different body returns 409.

        • Optionaltype?: string

          Schema type identifier (lookup_key) of the object. Optional; used for routing context only.

      Returns Promise<
          {
              data: {
                  acl?: {
                      add?: {
                          actions: string[];
                          principal?: string;
                          principal_type: string;
                      }[];
                      add_denies?: {
                          actions: string[];
                          principal?: string;
                          principal_type: string;
                      }[];
                      denies?: {
                          actions: string[];
                          principal?: string;
                          principal_type: string;
                      }[];
                      grants?: {
                          actions: string[];
                          principal?: string;
                          principal_type: string;
                      }[];
                      preserve_denies?: boolean;
                      remove?: { principal?: string; principal_type: string }[];
                      remove_denies?: { principal?: string; principal_type: string }[];
                  };
                  agent?: string;
                  created_at?: string;
                  expires_at?: string
                  | null;
                  fields?: Record<string, unknown>;
                  id: string;
                  org?: string;
                  row_key?: string;
                  sandbox?: string;
                  schema_type?: string;
                  team?: string;
                  updated_at?: string;
                  user?: string;
                  version?: number;
              };
              meta?: Record<string, unknown>;
          },
      >

      Successful response