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

# Start a Monerium link

> Starts the connection of a Safe to a Monerium account. The route asks the Safe,
through ERC-1271, whether it accepts the owner signature over the Monerium
address-link message. Only then does it start the Monerium sign-in and return the
URL to send the browser to. Nothing goes on chain.

- Who may call: the owners of the Safe, from a browser.
- Before: the Safe has the Anafi off-ramp handler as its fallback handler. The owners
  sign the Safe EIP-712 `SafeMessage` (domain: `chainId` and `verifyingContract` =
  the Safe) whose `message` is the EIP-191 hash of the text
  `I hereby declare that I am the address owner.`
- Send the request with credentials (`credentials: "include"`). The answer sets a
  cookie that binds the flow to this browser. Without the cookie, the flow cannot
  finish.
- Guarantee: after consent at Monerium, Anafi sends the browser to the Anafi dapp
  with the query `monerium=connected`, or `monerium=error` and a `reason`.

Served only on `polygon-amoy`. See [Bank payouts](/flows/bank-payouts) and
[Off-ramp handler](/contracts/off-ramp-handler).




## OpenAPI

````yaml /api/openapi.yaml post /api/monerium/connect
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/monerium/connect:
    post:
      tags:
        - Bank payouts
      summary: Start a Monerium link
      description: >
        Starts the connection of a Safe to a Monerium account. The route asks
        the Safe,

        through ERC-1271, whether it accepts the owner signature over the
        Monerium

        address-link message. Only then does it start the Monerium sign-in and
        return the

        URL to send the browser to. Nothing goes on chain.


        - Who may call: the owners of the Safe, from a browser.

        - Before: the Safe has the Anafi off-ramp handler as its fallback
        handler. The owners
          sign the Safe EIP-712 `SafeMessage` (domain: `chainId` and `verifyingContract` =
          the Safe) whose `message` is the EIP-191 hash of the text
          `I hereby declare that I am the address owner.`
        - Send the request with credentials (`credentials: "include"`). The
        answer sets a
          cookie that binds the flow to this browser. Without the cookie, the flow cannot
          finish.
        - Guarantee: after consent at Monerium, Anafi sends the browser to the
        Anafi dapp
          with the query `monerium=connected`, or `monerium=error` and a `reason`.

        Served only on `polygon-amoy`. See [Bank payouts](/flows/bank-payouts)
        and

        [Off-ramp handler](/contracts/off-ramp-handler).
      operationId: connectMonerium
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MoneriumConnectRequest'
            example:
              aaAddress: '0xf9836de53d455019ed985896fce8af80be66b7f9'
              addressLinkSignature: >-
                0x4381dc2ab14285160c808659aee005d51255add7264b318d07c7417292c7442c19f0e2d4c6b8a0f1e3d5c7b9a1f3e5d7c9b0a2f4e6d8c1b3a5f7e9d0c2b4a6f81f
      responses:
        '200':
          description: The Safe accepted the signature. Send the browser to `authorizeUrl`.
          headers:
            Set-Cookie:
              description: >-
                An `HttpOnly`, `Secure`, `SameSite=Lax` cookie that binds the
                flow to this browser. Keep it.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MoneriumConnectResponse'
        '400':
          description: >-
            The signature is empty (JSON body), or the body is not valid JSON
            (plain text).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MoneriumErrorResponse'
            text/plain:
              schema:
                $ref: '#/components/schemas/PlainTextError'
        '403':
          description: >-
            The Safe does not accept the signature. The owners did not sign, too
            few signed, or the fallback handler of the Safe is not the off-ramp
            handler.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MoneriumErrorResponse'
        '413':
          $ref: '#/components/responses/BodyTooLarge'
        '415':
          $ref: '#/components/responses/MissingJsonContentType'
        '422':
          $ref: '#/components/responses/JsonBodyRejected'
        '500':
          description: The Anafi API could not store the flow. Try again later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MoneriumErrorResponse'
              example:
                error: storage error
        '503':
          description: The Safe could not be asked. Try again later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MoneriumErrorResponse'
      servers:
        - url: https://api.polygon-amoy.ana.fi
          description: Polygon Amoy testnet (Monerium sandbox)
components:
  schemas:
    MoneriumConnectRequest:
      type: object
      required:
        - aaAddress
        - addressLinkSignature
      properties:
        aaAddress:
          $ref: '#/components/schemas/Address'
          description: >-
            The Safe to connect. Its fallback handler must be the off-ramp
            handler.
        addressLinkSignature:
          $ref: '#/components/schemas/HexBytes'
          description: >-
            The owner signatures over the Safe `SafeMessage` of the address-link
            hash, in the format that the ERC-1271 check of the Safe takes. Must
            not be empty.
    MoneriumConnectResponse:
      type: object
      required:
        - authorizeUrl
      properties:
        authorizeUrl:
          type: string
          format: uri
          description: The Monerium page to send the browser to.
    MoneriumErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: A sentence that says why the route refused.
    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'
    HexBytes:
      type: string
      pattern: ^0x([0-9a-fA-F]{2})*$
      description: Bytes as `0x` and an even count of hex digits.
  responses:
    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`'
    JsonBodyRejected:
      description: >-
        The body is valid JSON, but a field is missing or has the wrong type or
        format.
      content:
        text/plain:
          schema:
            $ref: '#/components/schemas/PlainTextError'
          example: >-
            Failed to deserialize the JSON body into the target type: missing
            field `eoa` at line 1 column 2

````

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