> ## Documentation Index
> Fetch the complete documentation index at: https://puzzlet-9ba7bb98.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Ingest coding-agent sessions (outerlayer sync)

> Ingests a batch of canonical AgentSessions (schemaVersion 1) plus their content-addressed image blobs. Each session is tier-clamped to the tenant ceiling, secret-scrubbed, and mapped to spans. Deterministic ids make re-sync idempotent. Sessions are validated individually: a malformed session is rejected without failing the batch.



## OpenAPI

````yaml /openapi.yaml post /v1/agents/sync
openapi: 3.0.3
info:
  contact:
    email: hello@agentmark.co
    url: https://docs.agentmark.co
  description: >-
    The AgentMark Gateway API lets you ingest traces, create scores, and
    retrieve prompt templates programmatically.


    Most developers should use the [AgentMark SDK](/introduction/overview) for
    integration.

    The REST API is for cases where you need direct HTTP access or are building
    a custom integration.


    Versioning: every endpoint is prefixed with `/v1/`. Breaking changes ship
    under a new version prefix (`/v2/`, etc.) with a 90-day-minimum deprecation
    window — see [API versioning & stability](/api-reference/versioning) for the
    full policy on what constitutes a breaking vs. additive change.
  title: AgentMark Gateway API
  version: '1.0'
servers:
  - description: Production (AgentMark Cloud)
    url: https://api.agentmark.co
  - description: Local dev server (`npx @agentmark-ai/cli dev`)
    url: http://localhost:9418
security:
  - AppId: []
    BearerAuth: []
tags:
  - description: Ingest, query, and export OpenTelemetry trace data.
    name: Traces
  - description: >-
      Coding-agent session ingest (outerlayer sync) and content-addressed
      session images.
    name: Agents
  - description: >-
      Eval trial-result ingest: per-trial score rows plus full-fidelity artifact
      blobs.
    name: Evals
  - description: Query individual spans across traces.
    name: Spans
  - description: Create, retrieve, list, and delete score records for spans and traces.
    name: Scoring
  - description: Structured-filter search across observability resources.
    name: Search
  - description: Query server feature availability.
    name: Capabilities
  - description: Per-model LLM pricing data. Public, unauthenticated.
    name: Pricing
  - description: >-
      Create, list, and revoke tenant API keys. Plaintext returned exactly once
      at creation.
    name: API Keys
  - description: >-
      List and retrieve score configuration definitions from the synced project
      config.
    name: Score Configs
  - description: Per-app named environments (e.g. `dev`, `prod`). CRUD for env lifecycle.
    name: Environments
  - description: >-
      App CRUD — the top-level tenant entity every other resource hangs off.
      Lets a headless agent provision an app without the dashboard.
    name: Apps
  - description: >-
      Cloud workers — terminal coding agents on managed compute. Launch one-shot
      runs or persistent multi-turn sessions against the app's connected repo;
      every response carries the dashboard deep link to the live thread.
    name: Workers
  - description: Service health checks.
    name: Health
paths:
  /v1/agents/sync:
    post:
      tags:
        - Agents
      summary: Ingest coding-agent sessions (outerlayer sync)
      description: >-
        Ingests a batch of canonical AgentSessions (schemaVersion 1) plus their
        content-addressed image blobs. Each session is tier-clamped to the
        tenant ceiling, secret-scrubbed, and mapped to spans. Deterministic ids
        make re-sync idempotent. Sessions are validated individually: a
        malformed session is rejected without failing the batch.
      operationId: sync-agent-sessions
      requestBody:
        content:
          application/json:
            schema:
              properties:
                blobs:
                  items:
                    properties:
                      bytes:
                        minimum: 0
                        type: integer
                      data:
                        minLength: 1
                        type: string
                      mediaType:
                        maxLength: 100
                        minLength: 1
                        type: string
                      sha256:
                        pattern: ^[0-9a-f]{64}$
                        type: string
                    required:
                      - sha256
                      - mediaType
                      - bytes
                      - data
                    type: object
                  maxItems: 64
                  type: array
                schemaVersion:
                  enum:
                    - 1
                  type: number
                sessions:
                  items:
                    nullable: true
                  maxItems: 50
                  minItems: 1
                  type: array
              required:
                - schemaVersion
                - sessions
              type: object
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  data:
                    properties:
                      accepted:
                        items:
                          type: string
                        type: array
                      blobsStored:
                        type: integer
                      rejected:
                        items:
                          properties:
                            id:
                              type: string
                            index:
                              type: integer
                            reason:
                              type: string
                          required:
                            - index
                            - reason
                          type: object
                        type: array
                      spanRows:
                        type: integer
                      tenantTier:
                        enum:
                          - metrics
                          - redacted
                          - full
                        type: string
                    required:
                      - accepted
                      - rejected
                      - spanRows
                      - blobsStored
                      - tenantTier
                    type: object
                required:
                  - data
                type: object
          description: 'Batch result: accepted/rejected per session.'
        '400':
          content:
            application/json:
              schema:
                properties:
                  error:
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    type: object
                required:
                  - error
                type: object
          description: Malformed request body.
        '401':
          content:
            application/json:
              schema:
                properties:
                  error:
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    type: object
                required:
                  - error
                type: object
          description: Missing or invalid API key.
        '413':
          content:
            application/json:
              schema:
                properties:
                  error:
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    type: object
                required:
                  - error
                type: object
          description: >-
            Batch exceeds the per-request byte ceiling — split it into smaller
            requests.
        '429':
          content:
            application/json:
              schema:
                properties:
                  error:
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    type: object
                required:
                  - error
                type: object
          description: Monthly unit limit exceeded.
        '503':
          content:
            application/json:
              schema:
                properties:
                  error:
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    type: object
                required:
                  - error
                type: object
          description: Ingest temporarily unavailable; retry after the interval.
          headers:
            Retry-After:
              required: false
              schema:
                minimum: 0
                type: integer
components:
  securitySchemes:
    AppId:
      description: >-
        Application ID for tenant scoping. X-Outerlayer-App-Id is accepted as an
        equivalent header.
      in: header
      name: X-Agentmark-App-Id
      type: apiKey
    BearerAuth:
      description: API key (sk_agentmark_*)
      scheme: bearer
      type: http

````