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

# Read back account state

> Returns the rule document of the account in plain text, the account state, and the
verified notification email, sealed so that only the caller can open it. The engine
signs the reply. The Anafi API passes the envelope and the reply through without
reading them.

- Who may call: an owner (a signer) of the account, with an EIP-4361 sign-in.
- Sign-in domain: the engine accepts the sign-in only when the message names the
  domain of the Anafi dapp, `app.ana.fi`. A sign-in for another domain is refused
  with `422`. An integration on another domain cannot complete this flow today.
- Before: sign the sign-in message, put it in the sealed payload with `aa` and the
  signature, and seal it under `anafi/confidential-call/req/v1`. See
  [Sealed requests](/api-reference/sealed-requests).
- Guarantee: the opened reply holds `engine_sig`, the signature of `engineSigKey`
  over the state and the nonce of your sign-in. Check it before you trust the state.

Each sign-in works once. It is valid for 5 minutes after its `Issued At`. A refusal
after the signature check can use up the nonce, so sign a new message to try again.




## OpenAPI

````yaml /api/openapi.yaml post /api/wallets/{aa}/recover
openapi: 3.1.0
info:
  title: Anafi API
  version: 0.3.0
  summary: The public HTTP API of one Anafi network.
  description: >
    The Anafi API is the HTTP surface of one Anafi network. Each network has its
    own host.

    The public TypeScript SDK `@anafi-cc/anafi-sdk` calls these routes for you,
    and it also

    builds and checks the signed and sealed payloads. You can call the routes
    directly.


    - No API key is necessary today.

    - Request and response bodies are JSON, except where an operation says
    otherwise.

    - A route that carries a confidential payload takes an HPKE-sealed envelope.
    Read
      [Sealed requests](/api-reference/sealed-requests) before you call it without the SDK.
    - Read [Introduction](/api-reference/introduction) for formats and
      [Errors](/api-reference/errors) for the error bodies.

    Browser origin: the API hosts answer CORS only for `https://app.ana.fi`
    today. A browser

    page on another origin cannot call the API directly. A server, a script, or
    your own

    same-origin proxy can call it.
servers:
  - url: https://api.polygon.ana.fi
    description: Polygon PoS (chain id 137)
  - url: https://api.xlayer.ana.fi
    description: X Layer (chain id 196)
  - url: https://api.polygon-amoy.ana.fi
    description: Polygon Amoy testnet (chain id 80002)
security: []
tags:
  - name: Accounts
    description: >-
      Find the accounts of an owner address, and deploy the 1-of-1 Safe of an
      owner.
  - name: Safe relay
    description: Submit an owner-signed Safe transaction. Anafi pays the gas.
  - name: Rules
    description: >-
      Stage a sealed rule document. The engine returns the attestation for the
      on-chain commit.
  - name: Confidential channel
    description: >-
      Read back the rule document and the account state of an account through a
      sealed channel.
  - name: Notification email
    description: Verify the email address that rule notifications go to.
  - name: Activity
    description: Read the payments that the engine made for an account.
  - name: Fees
    description: Read the fee terms of the network and the sponsorship of an account.
  - name: Payments
    description: Ask for the email receipt of a payment made on the pay page.
  - name: Rule language
    description: >-
      Read the rule language reference, and write a rule document from a
      description.
  - name: Bank payouts
    description: >
      Connect a Safe to Monerium for bank payouts in euro, and read the state of
      the

      connection and of the orders. These routes are served only on
      `polygon-amoy`

      (Monerium sandbox). The `polygon` and `xlayer` hosts answer `404`.
  - name: Status
    description: Check that the Anafi API answers.
paths:
  /api/wallets/{aa}/recover:
    post:
      tags:
        - Confidential channel
      summary: Read back account state
      description: >
        Returns the rule document of the account in plain text, the account
        state, and the

        verified notification email, sealed so that only the caller can open it.
        The engine

        signs the reply. The Anafi API passes the envelope and the reply through
        without

        reading them.


        - Who may call: an owner (a signer) of the account, with an EIP-4361
        sign-in.

        - Sign-in domain: the engine accepts the sign-in only when the message
        names the
          domain of the Anafi dapp, `app.ana.fi`. A sign-in for another domain is refused
          with `422`. An integration on another domain cannot complete this flow today.
        - Before: sign the sign-in message, put it in the sealed payload with
        `aa` and the
          signature, and seal it under `anafi/confidential-call/req/v1`. See
          [Sealed requests](/api-reference/sealed-requests).
        - Guarantee: the opened reply holds `engine_sig`, the signature of
        `engineSigKey`
          over the state and the nonce of your sign-in. Check it before you trust the state.

        Each sign-in works once. It is valid for 5 minutes after its `Issued
        At`. A refusal

        after the signature check can use up the nonce, so sign a new message to
        try again.
      operationId: recoverWalletState
      parameters:
        - $ref: '#/components/parameters/AccountPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SealedRelayRequest'
      responses:
        '200':
          description: The sealed reply. Open it with the response key of your request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SealedResponse'
        '400':
          $ref: '#/components/responses/InvalidPathOrJson'
        '413':
          $ref: '#/components/responses/BodyTooLarge'
        '415':
          $ref: '#/components/responses/MissingJsonContentType'
        '422':
          description: >
            The engine refused the request. The envelope did not open, the
            payload is not

            valid, the sealed `aa` is not the path `aa`, the sign-in failed a
            check (signature,

            domain, chain, time window, a `Resources` list), the nonce was used
            before, or the

            signer is not a signer of the account. A plain-text body from the
            Anafi API means

            that a JSON field is missing or has the wrong type.
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/PlainTextError'
              examples:
                invalid:
                  value: invalid recover request
                replay:
                  value: stale or replayed request
                signer:
                  value: signer is not a signer of the wallet
        '500':
          description: >-
            The engine could not read its records, sign or seal the reply. Sign
            a new message and try again later.
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/PlainTextError'
        '502':
          description: >-
            The engine could not be reached, or could not read the authorization
            state of the account. Sign a new message and try again later.
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/PlainTextError'
              example: engine unreachable
components:
  parameters:
    AccountPath:
      name: aa
      in: path
      required: true
      description: >-
        The account address (a Safe or a plain address), as `0x` and 40 hex
        digits in any letter case.
      schema:
        $ref: '#/components/schemas/Address'
      example: '0xf9836de53d455019ed985896fce8af80be66b7f9'
  schemas:
    SealedRelayRequest:
      type: object
      description: >-
        The body of every route that carries a sealed request. The Anafi API
        passes `sealed` to the engine unchanged and takes the account from the
        path.
      required:
        - sealed
      properties:
        sealed:
          $ref: '#/components/schemas/SealedEnvelope'
    SealedResponse:
      type: object
      description: >
        A reply sealed with ChaCha20-Poly1305 under the response key that the
        caller

        exported from the HPKE context of the request. Each field is a JSON
        array of byte

        values. See [Sealed requests](/api-reference/sealed-requests).
      required:
        - nonce
        - ct
      properties:
        nonce:
          type: array
          description: The 12-byte AEAD nonce.
          minItems: 12
          maxItems: 12
          items:
            type: integer
            minimum: 0
            maximum: 255
        ct:
          type: array
          description: The ciphertext with its 16-byte AEAD tag.
          minItems: 16
          items:
            type: integer
            minimum: 0
            maximum: 255
    PlainTextError:
      type: string
      description: >-
        A short English sentence. Show it or log it. Do not parse it; branch on
        the status code.
    Address:
      type: string
      pattern: ^0x[0-9a-fA-F]{40}$
      description: >-
        A 20-byte address as `0x` and 40 hex digits. Requests accept any letter
        case. Responses use lowercase.
      examples:
        - '0xf9836de53d455019ed985896fce8af80be66b7f9'
    SealedEnvelope:
      type: object
      description: >
        An HPKE-sealed request. Each field is a JSON array of byte values
        (integers from 0 to

        255), not a hex string. The key names are snake_case. See

        [Sealed requests](/api-reference/sealed-requests).
      required:
        - kem_pk
        - ct
      additionalProperties: false
      properties:
        kem_pk:
          type: array
          description: >-
            The encapsulated key of the sender, an ephemeral X25519 public key
            of 32 bytes.
          minItems: 32
          maxItems: 32
          items:
            type: integer
            minimum: 0
            maximum: 255
        ct:
          type: array
          description: >-
            The ciphertext, which is the sealed payload and the 16-byte AEAD
            tag.
          minItems: 16
          items:
            type: integer
            minimum: 0
            maximum: 255
  responses:
    InvalidPathOrJson:
      description: The `aa` path segment is not an address, or the body is not valid JSON.
      content:
        text/plain:
          schema:
            $ref: '#/components/schemas/PlainTextError'
          example: >-
            Failed to parse the request body as JSON: EOF while parsing an
            object at line 1 column 1
    BodyTooLarge:
      description: >-
        The body is larger than the limit of the route. The limit is 2 MB for
        `POST /api/dsl/generate` and the bank payout routes, and 512 KiB for all
        other routes.
      content:
        text/plain:
          schema:
            $ref: '#/components/schemas/PlainTextError'
    MissingJsonContentType:
      description: 'The request has no `Content-Type: application/json` header.'
      content:
        text/plain:
          schema:
            $ref: '#/components/schemas/PlainTextError'
          example: 'Expected request with `Content-Type: application/json`'

````

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