> ## 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.

# Request an email code

> Asks the engine to send a 6-digit verification code to an email address for the
account. A rule document can name only the verified email of its account.

- Who may call: an owner of the account, with an EIP-4361 sign-in whose single
  `Resources` entry binds the account and the canonical email.
- 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: seal `adapter`, `email`, `siwe_message` and `signature` under
  `anafi/notification-email/request-code/<network>/` plus the 20 address bytes of
  `aa`. See [Sealed requests](/api-reference/sealed-requests).
- Guarantee: the opened reply has an `outcome`. With `code_issued`, keep
  `code_token` for `verify_code`. The code is valid for 15 minutes.

The answer is `200` also when no mail goes out: read `outcome.kind`. See
[Notification email flow](/flows/notification-email).




## OpenAPI

````yaml /api/openapi.yaml post /api/wallets/{aa}/notification_email/request_code
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}/notification_email/request_code:
    post:
      tags:
        - Notification email
      summary: Request an email code
      description: >
        Asks the engine to send a 6-digit verification code to an email address
        for the

        account. A rule document can name only the verified email of its
        account.


        - Who may call: an owner of the account, with an EIP-4361 sign-in whose
        single
          `Resources` entry binds the account and the canonical email.
        - 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: seal `adapter`, `email`, `siwe_message` and `signature` under
          `anafi/notification-email/request-code/<network>/` plus the 20 address bytes of
          `aa`. See [Sealed requests](/api-reference/sealed-requests).
        - Guarantee: the opened reply has an `outcome`. With `code_issued`, keep
          `code_token` for `verify_code`. The code is valid for 15 minutes.

        The answer is `200` also when no mail goes out: read `outcome.kind`. See

        [Notification email flow](/flows/notification-email).
      operationId: requestNotificationEmailCode
      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 or its payload did not
            open, the

            named adapter is not live on this chain, or the sign-in failed a
            check (signature,

            domain, chain, time window, resource, single use, 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'
              example: could not authenticate the notification-email sign-in
        '500':
          description: >-
            The engine could not store the request or seal the reply. Try again
            later with a new sign-in.
          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. Try again later with a new sign-in.
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/PlainTextError'
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.