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

# Session status

> Says who the bearer token signed in as, the subscription it acts under as the chain has it now, and how many rounds the current term has used. The token is resolved exactly as on `POST /v1/round/execute`: an unknown, expired or revoked token is `401` and costs no chain read.

`subscription` is read from chain for this request, once (the same read a round makes, through the same short cache). `subscription.active` says the signed-in key may run rounds under it now: the term has not ended and, for a delegate, its delegate account exists. An inactive, absent or lapsed subscription is still `200`, with `active: false` and `usage: null`; its fields are zero when the subscription or delegate account does not exist.

`usage` is the gateway's own count for the current term, the 30-day step counted back from `validUntil` that ends at `usage.termEndsAt`; the counters reset when the next term begins. `used` is every key's rounds under the subscription, `usedByYou` the signed-in key's own. The plan allows `subscription.maxRounds` per term owner-wide, and a delegate at most `delegate.maxRounds` of its own (`delegate` is `null` for an owner). The count includes rounds reserved and not yet served.

Says who the bearer token signed in as, the subscription it acts under as the chain has it now, and how many rounds the current term has used. An unknown, expired or revoked token is `401` and costs no chain read.

* `role` is `owner` or `delegate`.
* `subscription.active` says the signed-in key may run rounds now: the term has not ended and, for a delegate, its delegate account exists. An inactive or missing subscription is still `200`, with `active: false` and `usage: null`.
* `usage.used` counts every key's rounds under the subscription this term, and `usage.usedByYou` the signed-in key's own. The count includes rounds reserved and not yet served. The counters reset at `usage.termEndsAt`.
* `subscription.maxRounds` is the owner-wide quota per term. `delegate.maxRounds` is a delegate's own cap, the smaller of the plan's quota and the delegate's `max_data_requests`; `delegate` is `null` for an owner.

> [!NOTE]
>
> Served only when [`GET /v1/info`](https://docs.molpha.io/gateways/api/info) reports `sessionAuth: true`; otherwise this route returns `404`.


## OpenAPI

````yaml gateway-openapi.yaml GET /v1/session
openapi: 3.1.0
info:
  contact: {}
  description: >-
    HTTP entry point to the Molpha oracle protocol. The gateway dispatches
    oracle rounds to nodes over libp2p, waits for threshold Schnorr signatures
    delivered directly by the nodes, and returns signed payloads. The x402
    endpoints (`/v1/x402/*`) are always served and require a configured trusted
    facilitator.
  title: Molpha Gateway API
  version: '1.0'
  x-mint:
    metadata:
      description: >-
        Run oracle rounds, sign in, preview sources and read the node set of a
        Molpha gateway.
servers:
  - url: https://gateway.molpha.io
    description: Devnet
security: []
tags:
  - name: health
    description: Liveness
  - name: gateway
    description: Gateway identity, program and authentication settings
  - name: nodes
    description: The on-chain node set
  - name: providers
    description: Integrated data providers
  - name: round
    description: Subscription and delegate rounds
  - name: session
    description: Sign-in sessions (served when `GET /v1/info` reports `sessionAuth` true)
  - name: source
    description: Unsigned source preview and simulation
  - name: x402
    description: x402 pay-per-request rounds
paths:
  /v1/session:
    get:
      tags:
        - session
      summary: Session status
      description: >-
        Says who the bearer token signed in as, the subscription it acts under
        as the chain has it now, and how many rounds the current term has used.
        The token is resolved exactly as on `POST /v1/round/execute`: an
        unknown, expired or revoked token is `401` and costs no chain read.


        `subscription` is read from chain for this request, once (the same read
        a round makes, through the same short cache). `subscription.active` says
        the signed-in key may run rounds under it now: the term has not ended
        and, for a delegate, its delegate account exists. An inactive, absent or
        lapsed subscription is still `200`, with `active: false` and `usage:
        null`; its fields are zero when the subscription or delegate account
        does not exist.


        `usage` is the gateway's own count for the current term, the 30-day step
        counted back from `validUntil` that ends at `usage.termEndsAt`; the
        counters reset when the next term begins. `used` is every key's rounds
        under the subscription, `usedByYou` the signed-in key's own. The plan
        allows `subscription.maxRounds` per term owner-wide, and a delegate at
        most `delegate.maxRounds` of its own (`delegate` is `null` for an
        owner). The count includes rounds reserved and not yet served.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionStatusResponse'
        '401':
          description: >-
            Missing bearer token, or the token is unknown, expired or revoked;
            sign in again
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: >-
            Transient chain-read or storage failure; retry after the Retry-After
            header
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    SessionStatusResponse:
      properties:
        data:
          $ref: '#/components/schemas/SessionStatusData'
        status:
          example: ok
          type: string
      type: object
    ErrorResponse:
      properties:
        error:
          example: validation failed
          type: string
      type: object
    SessionStatusData:
      properties:
        authority:
          description: >-
            Authority is the key that signed in; Owner the subscription it acts
            under.
          example: 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
          type: string
        delegate:
          allOf:
            - $ref: '#/components/schemas/SessionStatusDelegate'
          description: >-
            Delegate is the delegate's own cap; null for an owner, and for a
            delegate whose delegate account no longer exists.
          nullable: true
        expiresAt:
          description: ExpiresAt is when the session ends.
          example: 1791376200
          type: integer
        owner:
          example: 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
          type: string
        role:
          description: Role is "owner" or "delegate".
          example: owner
          type: string
        sessionId:
          example: 9f2c4e6a8b0d1f3a5c7e9b1d3f5a7c9e
          type: string
        subscription:
          $ref: '#/components/schemas/SessionStatusSubscription'
        usage:
          allOf:
            - $ref: '#/components/schemas/SessionStatusUsage'
          description: >-
            Usage is the current term's quota use; null when the subscription is
            not active.
          nullable: true
      type: object
    SessionStatusDelegate:
      properties:
        maxRounds:
          description: >-
            MaxRounds is the per-term cap on this delegate's own rounds: the
            smaller of the plan's maxRounds and the delegate's limit.
          example: 5000
          type: integer
      type: object
    SessionStatusSubscription:
      properties:
        active:
          description: >-
            Active says the signed-in key may run rounds under the subscription
            now.
          example: true
          type: boolean
        maxRounds:
          description: MaxRounds is the plan's per-term round quota, owner-wide.
          example: 100000
          type: integer
        maxSigners:
          example: 5
          type: integer
        validUntil:
          example: 1793966400
          type: integer
      type: object
    SessionStatusUsage:
      properties:
        termEndsAt:
          description: TermEndsAt is when the current term ends and the counters reset.
          example: 1791892800
          type: integer
        used:
          description: >-
            Used counts rounds charged to the subscription this term, by every
            key.
          example: 1234
          type: integer
        usedByYou:
          description: UsedByYou counts the signed-in key's own rounds this term.
          example: 321
          type: integer
      type: object
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Session token from `POST /v1/session`, sent as `Authorization: Bearer
        <token>`. Required for `GET /v1/session` and `DELETE /v1/session`. On
        `POST /v1/round/execute` it is optional and replaces RequestAuth
        (`authSig` and `authTimestamp` in the body); sending both is `400`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.