> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentsfleet.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Poll for the next lease

> The poll a runner lives on. Answers either a lease to run or a backoff to wait out. The claim, the money, the gates and the policy are all decided before the answer is written. 



## OpenAPI

````yaml https://raw.githubusercontent.com/agentsfleet/agentsfleet/main/public/openapi.json post /v1/runners/me/leases
openapi: 3.1.0
info:
  title: agentsfleet Control Plane API
  description: API for managing workspaces, fleets, triggers, and runs.
  contact:
    name: agentsfleet
    url: https://agentsfleet.net
  license:
    name: MIT
    identifier: MIT
  version: 1.0.0
servers:
  - url: https://api.agentsfleet.net
    description: Production
security: []
paths:
  /v1/runners/me/leases:
    post:
      tags:
        - Runners
      summary: Poll for the next lease
      description: >-
        The poll a runner lives on. Answers either a lease to run or a backoff
        to wait out. The claim, the money, the gates and the policy are all
        decided before the answer is written. 
      operationId: runner_lease
      responses:
        '200':
          description: A lease to run, or a backoff to wait out
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LeaseResponse'
        '401':
          description: No credential, or one this route does not accept
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemBody'
        '403':
          description: The credential is good and lacks the capability this route requires
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemBody'
        '429':
          description: The instance is at its ceiling
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemBody'
        '500':
          description: The daemon failed to answer
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemBody'
        '503':
          description: A dependency this route needs is unreachable
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemBody'
      security:
        - RunnerBearerAuth: []
components:
  schemas:
    LeaseResponse:
      type: object
      description: >-
        `POST /v1/runners/me/leases` reply. Always `200`.


        `lease` is the work, or null with `retry_after_ms` set when there is
        none —

        a backoff hint rather than a `204`.
      properties:
        lease:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/LeasePayload'
              description: The work, when there is any.
        retry_after_ms:
          type:
            - integer
            - 'null'
          format: int32
          description: How long to wait before asking again, when there is none.
          minimum: 0
    ProblemBody:
      type: object
      description: The body every refusal carries, under `application/problem+json`.
      required:
        - docs_uri
        - title
        - detail
        - error_code
        - request_id
      properties:
        action_id:
          type:
            - string
            - 'null'
          description: 'On that 409 only: the action the gate held.'
        current_state:
          type:
            - string
            - 'null'
          description: 'On a 409 only: the state that forbade the transition.'
        detail:
          type: string
          description: One sentence on what was refused and why.
        docs_uri:
          type: string
          description: Where the error code is documented.
        error_code:
          type: string
          description: The registry code, stable across releases.
        etag:
          type:
            - string
            - 'null'
          description: >-
            On a 412 only: the resource's current entity tag, to refetch and
            retry.
        gate_id:
          type:
            - string
            - 'null'
          description: 'On an answered approval gate''s 409 only: the gate that was answered.'
        missing_secrets:
          type:
            - array
            - 'null'
          items:
            type: string
          description: 'On a 424 only: the credentials this workspace has yet to store.'
        outcome:
          type:
            - string
            - 'null'
          description: 'On that 409 only: the answer that stands.'
        request_id:
          type: string
          description: The request this refusal answers, for support.
        resolved_at:
          type:
            - integer
            - 'null'
          format: int64
          description: 'On that 409 only: when the standing answer was given.'
        resolved_by:
          type:
            - string
            - 'null'
          description: 'On that 409 only: who gave it.'
        title:
          type: string
          description: A short name for the refusal, safe to show a person.
        user_message:
          type:
            - string
            - 'null'
          description: A curated sentence for end users, where the code has one.
    LeasePayload:
      type: object
      description: >-
        The work half of a lease.


        `fencing_token` is a monotonic guard: a report must echo it, and a stale

        holder carrying an older token is rejected. That is what makes reporting
        safe

        under lease reclaim, beyond plain idempotency by event id.
      required:
        - lease_id
        - fencing_token
        - lease_expires_at
        - secret_delivery
        - event
        - policy
        - instructions
      properties:
        bundle:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/BundleManifest'
              description: The bundle to materialize, when the fleet was created from one.
        event:
          $ref: '#/components/schemas/EventEnvelope'
          description: The event to run.
        fencing_token:
          type: integer
          format: int64
          description: Monotonic guard a report must echo.
          minimum: 0
        instructions:
          type: string
          description: >-
            The installed fleet's behaviour prose, so the sandboxed turn runs
            the

            installed behaviour rather than a generic one. Soft reasoning input
            —

            hard tool and secret policy stays in `policy`.
        lease_expires_at:
          type: integer
          format: int64
          description: Epoch milliseconds after which the event becomes reclaimable.
        lease_id:
          type: string
          description: Identifier for this lease.
        policy:
          $ref: '#/components/schemas/ExecutionPolicy'
          description: What the run is permitted to do.
        secret_delivery:
          $ref: '#/components/schemas/SecretDelivery'
          description: How secrets reached this run.
    BundleManifest:
      type: object
      description: >-
        Content-addressed reference to an installed Fleet Bundle's snapshot.


        The hash's presence on a lease IS the "has bundle" signal. A `404` from
        the

        download means the bundle is skill-only and the runner proceeds with
        none.
      required:
        - content_hash
      properties:
        content_hash:
          type: string
          description: Content hash addressing the immutable canonical archive.
      additionalProperties: false
    EventEnvelope:
      type: object
      description: >-
        One event on the wire, flat by convention.


        `request_json` is opaque JSON carried verbatim. The runner parses it to
        run

        the event, and the read endpoints return it unchanged.
      required:
        - event_id
        - fleet_id
        - workspace_id
        - actor
        - event_type
        - request_json
        - created_at
      properties:
        actor:
          type: string
          description: Who or what produced the event.
        created_at:
          type: integer
          format: int64
          description: Epoch milliseconds at which the event was created.
        event_id:
          type: string
          description: |-
            The canonical event identifier, the same on every surface that shows
            the event.
        event_type:
          $ref: '#/components/schemas/EventType'
          description: How the event entered the system.
        fleet_id:
          type: string
          description: The fleet this event belongs to.
        request_json:
          type: string
          description: Opaque request payload, carried verbatim.
        workspace_id:
          type: string
          description: The workspace the fleet belongs to.
    ExecutionPolicy:
      type: object
      description: Everything a single run is permitted to do.
      required:
        - network_policy
        - tools
        - mintable
        - provider
        - api_key
        - inference_host
        - http_origin_policies
        - context
      properties:
        api_key:
          type: string
          description: >-
            Provider credential for this run. Secret — never logged, never
            echoed.
        base_url:
          type:
            - string
            - 'null'
          description: Base URL override for a compatible provider.
        context:
          $ref: '#/components/schemas/ContextBudget'
          description: Context-budget knobs for the run.
        http_origin_policies:
          type: array
          items:
            $ref: '#/components/schemas/HttpOriginPolicy'
          description: Per-host request boundaries.
        inference_host:
          type: string
          description: Inference host to dial.
        mintable:
          type: array
          items:
            $ref: '#/components/schemas/Mintable'
          description: Credentials the run may mint on demand.
        network_policy:
          $ref: '#/components/schemas/NetworkPolicy'
          description: Where the run may reach on the network.
        provider:
          type: string
          description: Inference provider name.
        repository_binding:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/RepositoryBinding'
              description: Repositories the run is bound to, when it is bound to any.
        secrets_map:
          description: >-
            Static secrets substituted at the tool boundary. Free-form by
            design.
        tools:
          type: array
          items:
            type: string
          description: Tools the run may call.
      additionalProperties: false
    SecretDelivery:
      type: string
      description: How tenant secrets reach the runner.
      enum:
        - inline
        - scoped
        - proxy
    EventType:
      type: string
      description: How an event entered the system.
      enum:
        - chat
        - webhook
        - cron
        - continuation
    ContextBudget:
      type: object
      description: >-
        Context-budget knobs. `model` and `context_cap_tokens` are
        upstream-populated

        passthrough — the runner does not interpret `model`.
      required:
        - tool_window
        - memory_checkpoint_every
        - stage_chunk_threshold
        - model
        - context_cap_tokens
      properties:
        context_cap_tokens:
          type: integer
          format: int32
          description: The active model's context cap in tokens, or zero when unresolved.
          minimum: 0
        memory_checkpoint_every:
          type: integer
          format: int32
          description: How often a run checkpoints its memory.
          minimum: 0
        model:
          type: string
          description: The active model, carried through without interpretation.
        stage_chunk_threshold:
          type: number
          format: float
          description: Fill fraction at which a stage chunks rather than growing.
        tool_window:
          type: integer
          format: int32
          description: Tool results retained in the working window.
          minimum: 0
      additionalProperties: false
    HttpOriginPolicy:
      type: object
      description: The provider-neutral request boundary for one exact host.
      required:
        - host
        - credential_names
        - requests
      properties:
        credential_names:
          type: array
          items:
            type: string
          description: Credentials admitted at this host.
        host:
          type: string
          description: The host this boundary governs.
        requests:
          type: array
          items:
            $ref: '#/components/schemas/HttpRequestRule'
          description: Requests admitted at this host.
      additionalProperties: false
    Mintable:
      type: object
      description: >-
        One credential the lease grants the run permission to mint on demand.


        Carries the integration id ONLY — never a stored handle and never a
        token.

        The child mints a short-lived token at the tool boundary through the
        runner.
      required:
        - name
        - integration
      properties:
        integration:
          type: string
          description: >-
            The integration the broker mints for. The workspace is
            server-derived.
        name:
          type: string
          description: The placeholder name the fleet references.
      additionalProperties: false
    NetworkPolicy:
      type: object
      description: |-
        Per-run egress policy. An outbound request must match an entry in
        `allow` by exact hostname; an empty `allow` denies everything.
      required:
        - allow
        - read_only
        - read_post_paths
      properties:
        allow:
          type: array
          items:
            type: string
          description: Exact hostnames the run may reach.
        read_only:
          type: boolean
          description: >-
            Restrict tool requests to safe reads, keeping a credential from
            crossing

            to a host other than its own declared endpoint.
        read_post_paths:
          type: array
          items:
            type: string
          description: Exact prefixes where a read-only tool may use POST for a query.
      additionalProperties: false
    RepositoryBinding:
      type: object
      description: The repositories a run is bound to, and how it may use them.
      required:
        - repositories
        - access
        - base_branch
      properties:
        access:
          $ref: '#/components/schemas/RepositoryAccess'
          description: Whether the run may write to them.
        base_branch:
          type: string
          description: Branch a write is based on.
        repositories:
          type: array
          items:
            type: string
          description: Repositories the run may reach.
      additionalProperties: false
    HttpRequestRule:
      type: object
      description: |-
        One method and path admitted at an origin.

        JSON rules lock selected fields; any field the rules do not name stays
        available for request-specific content.
      required:
        - method
        - path
        - path_match
        - json_fields
      properties:
        json_fields:
          type: array
          items:
            $ref: '#/components/schemas/HttpJsonFieldRule'
          description: Fields whose values the rule locks.
        method:
          $ref: '#/components/schemas/HttpMethod'
          description: The method this rule admits.
        path:
          type: string
          description: The path this rule admits.
        path_match:
          $ref: '#/components/schemas/HttpPathMatch'
          description: Whether `path` is matched exactly or as a prefix.
      additionalProperties: false
    RepositoryAccess:
      type: string
      description: Whether a bound repository may be written or only read.
      enum:
        - read
        - write
    HttpJsonFieldRule:
      type: object
      description: One required top-level JSON field, with exactly one expected value set.
      required:
        - name
      properties:
        boolean_value:
          type:
            - boolean
            - 'null'
          description: Expected boolean value, when the rule locks a boolean.
        name:
          type: string
          description: The field name the rule locks.
        string_value:
          type:
            - string
            - 'null'
          description: Expected string value, when the rule locks a string.
      additionalProperties: false
    HttpMethod:
      type: string
      description: Methods a daemon-authored request rule may express.
      enum:
        - get
        - head
        - post
    HttpPathMatch:
      type: string
      description: Whether a request path must equal the authored bytes or begin with them.
      enum:
        - exact
        - prefix
  securitySchemes:
    RunnerBearerAuth:
      type: http
      scheme: bearer
      bearerFormat: agt_r
      description: The opaque agt_r token minted when the runner enrols (POST /v1/runners)

````