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

# Send a payment receipt

> Mails one receipt for one payment of the pay page to the address that the payer
typed. The route trusts no field before it checks it on chain: the transaction must
be mined and successful and must hold `Transfer(payer, payee, amountRaw)` of
`token`.

- Who may call: anyone. The request carries no proof that the caller is the payer,
  so a receipt holds only checked facts.
- Before: the payment transaction is mined, less than 1 hour ago. For `monthly`, the
  payer also has an `erc20_allow` permission for the token that is not blocked, a cap
  of the token at or above the amount, and a committed rule document.
- Guarantee: at most one confirmed mail for each transaction hash. A second request
  for the same hash answers `already_requested`. The route stores no mail and no
  email address.

The answer is `200` for every outcome of the checks: read `outcome.kind`. The SDK
function is `sendPayReceiptEmail`. See [Payments and subscriptions](/flows/payments-and-subscriptions).




## OpenAPI

````yaml /api/openapi.yaml post /api/pay/receipt_email
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/pay/receipt_email:
    post:
      tags:
        - Payments
      summary: Send a payment receipt
      description: >
        Mails one receipt for one payment of the pay page to the address that
        the payer

        typed. The route trusts no field before it checks it on chain: the
        transaction must

        be mined and successful and must hold `Transfer(payer, payee,
        amountRaw)` of

        `token`.


        - Who may call: anyone. The request carries no proof that the caller is
        the payer,
          so a receipt holds only checked facts.
        - Before: the payment transaction is mined, less than 1 hour ago. For
        `monthly`, the
          payer also has an `erc20_allow` permission for the token that is not blocked, a cap
          of the token at or above the amount, and a committed rule document.
        - Guarantee: at most one confirmed mail for each transaction hash. A
        second request
          for the same hash answers `already_requested`. The route stores no mail and no
          email address.

        The answer is `200` for every outcome of the checks: read
        `outcome.kind`. The SDK

        function is `sendPayReceiptEmail`. See [Payments and
        subscriptions](/flows/payments-and-subscriptions).
      operationId: sendPayReceiptEmail
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PayReceiptEmailRequest'
            example:
              email: payer@example.com
              txHash: >-
                0x2a4c6e8f0b1d3f5a7c9e1b3d5f7a9c1e3b5d7f9a1c3e5b7d9f1a3c5e7b9d1f3a
              payer: '0x000000000000000000000000000000000000dEaD'
              payee: '0x1111111111111111111111111111111111111111'
              token: '0x41e94eb019c0762f9bfcf9fb1e58725bfb0e7582'
              amountRaw: '25000000'
              mode: once
      responses:
        '200':
          description: The result of the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PayReceiptEmailResponse'
              examples:
                sent:
                  value:
                    outcome:
                      kind: sent
                retry:
                  value:
                    outcome:
                      kind: retry_after
                      seconds: 120
                invalid:
                  value:
                    outcome:
                      kind: invalid_email
        '400':
          $ref: '#/components/responses/MalformedJson'
        '413':
          $ref: '#/components/responses/BodyTooLarge'
        '415':
          $ref: '#/components/responses/MissingJsonContentType'
        '422':
          description: >
            `amountRaw` is 0, or is not a decimal integer of at most 256 bits,
            or a JSON field

            is missing or has the wrong type.
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/PlainTextError'
              example: amount must be a positive decimal integer of at most 256 bits
        '500':
          description: >-
            The Anafi API could not read or write its receipt records. Try again
            later.
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/PlainTextError'
              example: pay receipt storage failed
        '502':
          description: >-
            A chain read of the payment or of the monthly permission failed. Try
            again later.
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/PlainTextError'
              example: failed to read the payment from the chain
        '503':
          description: >-
            The engine did not answer the fee terms, or the sponsor record of
            the payer. Try again later.
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/PlainTextError'
              example: the fee terms or the sponsor record are unavailable
components:
  schemas:
    PayReceiptEmailRequest:
      type: object
      required:
        - email
        - txHash
        - payer
        - payee
        - token
        - amountRaw
        - mode
      properties:
        email:
          type: string
          description: >-
            The address that receives the receipt, as the payer typed it. It
            must be a bare ASCII mail address with no display name.
        txHash:
          $ref: '#/components/schemas/TxHash'
          description: The transaction of the payment.
        payer:
          $ref: '#/components/schemas/Address'
          description: The account that paid.
        payee:
          $ref: '#/components/schemas/Address'
          description: The address that got the payment.
        token:
          $ref: '#/components/schemas/Address'
          description: >-
            The ERC-20 contract of the payment. It must be a fee token of the
            network. The native coin is not accepted.
        amountRaw:
          $ref: '#/components/schemas/DecimalInteger'
          description: >-
            The amount in the smallest unit of `token`. It must be above 0 and
            fit in 256 bits.
        mode:
          $ref: '#/components/schemas/PayMode'
    PayReceiptEmailResponse:
      type: object
      required:
        - outcome
      properties:
        outcome:
          $ref: '#/components/schemas/PayReceiptEmailOutcome'
    PlainTextError:
      type: string
      description: >-
        A short English sentence. Show it or log it. Do not parse it; branch on
        the status code.
    TxHash:
      type: string
      pattern: ^0x[0-9a-f]{64}$
      description: A transaction hash as `0x` and 64 lowercase hex digits.
    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'
    DecimalInteger:
      type: string
      pattern: ^[0-9]+$
      description: >-
        A non-negative integer as a string of decimal digits, with no sign, no
        point and no exponent. Parse it as a big integer.
      examples:
        - '200000'
    PayMode:
      type: string
      oneOf:
        - const: once
          description: One plain ERC-20 transfer.
        - const: monthly
          description: The first payment of a monthly payment of an `erc20_allow` account.
    PayReceiptEmailOutcome:
      description: The result of a receipt request, tagged by `kind`.
      oneOf:
        - type: object
          title: sent
          description: The mail server accepted the receipt.
          required:
            - kind
          properties:
            kind:
              type: string
              const: sent
        - type: object
          title: already_requested
          description: >-
            A receipt for this transaction hash was sent, or is in progress. No
            mail was sent for this request.
          required:
            - kind
          properties:
            kind:
              type: string
              const: already_requested
        - type: object
          title: invalid_email
          description: The email is not a bare mail address. Ask the payer to correct it.
          required:
            - kind
          properties:
            kind:
              type: string
              const: invalid_email
        - type: object
          title: token_not_accepted
          description: >-
            The token is not a fee token of the network, or it is the native
            coin.
          required:
            - kind
          properties:
            kind:
              type: string
              const: token_not_accepted
        - type: object
          title: payment_not_found
          description: >-
            No mined, successful transaction with this hash holds the stated
            transfer. Ask again after the transaction is mined.
          required:
            - kind
          properties:
            kind:
              type: string
              const: payment_not_found
        - type: object
          title: payment_too_old
          description: The block of the payment is more than 1 hour old.
          required:
            - kind
          properties:
            kind:
              type: string
              const: payment_too_old
        - type: object
          title: monthly_setup_not_found
          description: >-
            For `monthly`, the chain does not show the permission, the cap or
            the committed document. Ask again after the setup is on chain.
          required:
            - kind
          properties:
            kind:
              type: string
              const: monthly_setup_not_found
        - type: object
          title: retry_after
          description: >-
            Too many receipt requests now. Send the request again after
            `seconds`.
          required:
            - kind
            - seconds
          properties:
            kind:
              type: string
              const: retry_after
            seconds:
              type: integer
              minimum: 0
              description: Whole seconds until you can send the request again.
        - type: object
          title: mail_not_configured
          description: This network sends no receipt mail.
          required:
            - kind
          properties:
            kind:
              type: string
              const: mail_not_configured
        - type: object
          title: not_sent
          description: The mail server did not accept the receipt. Ask again.
          required:
            - kind
          properties:
            kind:
              type: string
              const: not_sent
  responses:
    MalformedJson:
      description: 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.