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

# Create an invoice

<Note>
  CryptoProcessing is required to collect sender data in compliance with the MiCA regulations. For more details, see [**User data collection**](/api-reference/user-data-collection). The `sender_data` and the `end_user_reference` you provide must be associated with the same customer.
</Note>


## OpenAPI

````yaml POST /invoices/create
openapi: 3.0.0
info:
  title: Merchant Backend V2
  version: '1.0'
  description: Documentation for merchant backend processing endpoints
servers:
  - url: https://app.cryptoprocessing.com/api/v2
security:
  - xProcessingKey: []
tags:
  - name: Status
  - name: Balance
  - name: Currencies
  - name: Deposit addresses
  - name: Withdrawal
  - name: Exchange
  - name: Invoices
  - name: Transactions
paths:
  /invoices/create:
    post:
      tags:
        - Invoices
      summary: Create an invoice
      operationId: post-invoices-create
      parameters:
        - $ref: '#/components/parameters/XProcessingSignatureHeader'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                type:
                  type: string
                  description: >-
                    For partial pay invoices, set this parameter to
                    good_until_expired. For standard invoices, use fill_or_kill
                    or leave this parameter empty.
                  enum:
                    - fill_or_kill
                    - good_until_expired
                end_user_reference:
                  $ref: '#/components/schemas/end_user_reference'
                timer:
                  type: boolean
                  description: >-
                    If this parameter is set to true, the invoice will expire in
                    15 minutes after it is created.
                title:
                  type: string
                  maxLength: 50
                  description: Invoice title that the customer will see.
                  minLength: 1
                description:
                  type: string
                  description: Invoice description that the customer will see.
                  maxLength: 1000
                foreign_id:
                  type: string
                  description: This invoice's unique ID in your system.
                currency:
                  type: string
                  description: >-
                    Currency you want to receive deposits in. For a list of all
                    available currencies, see [API currency
                    codes](/api-reference/currency-codes).
                sender_currency:
                  type: string
                  description: >-
                    Currency the customer will pay in. If provided together with
                    `timer: true`, the invoice is created with a fixed payment
                    currency.
                amount:
                  type: number
                  description: Invoice amount that you want to receive from the customer.
                url_success:
                  type: string
                  format: uri
                  description: >-
                    The URL the customer will be redirected to in case of a
                    successful invoice payment.
                url_failed:
                  type: string
                  description: >-
                    The URL the customer will be redirected to in case of an
                    unsuccessful invoice payment.
                  format: uri
                email_user:
                  type: string
                  description: >-
                    If the amount the customer pays does not match the amount
                    you set for the invoice, Cryptoprocessing will send an email
                    to this address instructing the customer on how they can
                    receive a refund. If they paid less, they will receive a
                    full refund. If they paid more, the customer will get
                    instructions on how to be refunded the difference.
                  format: email
                sender_type:
                  type: string
                  enum:
                    - natural
                    - legal
                  description: >-
                    Whether the sender is a natural person (`natural`) or a
                    legal entity (`legal`). If you include the `sender_type`
                    parameter in the request, `sender_data` is also required.
                sender_data:
                  description: >-
                    If the sender is a natural person, include their
                    `first_name`, `last_name` and `date_of_birth`. If the sender
                    is a legal entity, include their `legal_name` and
                    `country_of_registration`.
                  type: object
                  required:
                    - first_name
                    - last_name
                    - date_of_birth
                    - legal_name
                    - country_of_registration
                  properties:
                    first_name:
                      $ref: '#/components/schemas/sender_data_first_name'
                    last_name:
                      $ref: '#/components/schemas/sender_data_last_name'
                    date_of_birth:
                      $ref: '#/components/schemas/sender_data_date_of_birth'
                    legal_name:
                      $ref: '#/components/schemas/sender_data_legal_name'
                    country_of_registration:
                      $ref: '#/components/schemas/sender_data_country_of_registration'
              required:
                - timer
                - title
                - foreign_id
                - end_user_reference
                - currency
                - sender_type
                - sender_data
                - amount
                - url_success
                - url_failed
                - email_user
            examples:
              Invoice without a timer:
                value:
                  timer: false
                  title: Invoice Title
                  currency: EUR
                  amount: 100
                  foreign_id: test_foreign_id_0344
                  end_user_reference: '12345'
                  url_success: https://example.com/success
                  url_failed: https://example.com/failed
                  email_user: email@example.com
                  sender_type: natural
                  sender_data:
                    first_name: Friedrich
                    last_name: Müller
                    date_of_birth: '1995-08-17'
              Invoice with a timer:
                value:
                  timer: true
                  title: Invoice Title
                  currency: EUR
                  amount: 100
                  foreign_id: test_foreign_id_0350
                  end_user_reference: '12345'
                  url_success: https://example.com/success
                  url_failed: https://example.com/failed
                  email_user: email@example.com
                  sender_type: natural
                  sender_data:
                    first_name: Friedrich
                    last_name: Müller
                    date_of_birth: '1995-08-17'
              Invoice with a timer and a pre-selected currency:
                value:
                  timer: true
                  title: Invoice Title
                  currency: EUR
                  sender_currency: BTC
                  amount: 100
                  foreign_id: test_foreign_id_0351
                  end_user_reference: '12345'
                  url_success: https://example.com/success
                  url_failed: https://example.com/failed
                  email_user: email@example.com
                  sender_type: natural
                  sender_data:
                    first_name: Friedrich
                    last_name: Müller
                    date_of_birth: '1995-08-17'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    required:
                      - id
                      - url
                      - foreign_id
                      - end_user_reference
                      - address
                      - title
                      - status
                      - currency
                      - amount
                      - sender_currency
                      - sender_amount
                      - fixed_at
                      - release_at
                      - seconds_left
                    properties:
                      id:
                        type: integer
                        format: int32
                        description: Invoice ID.
                        example: 123732
                      url:
                        type: string
                        format: uri
                        description: Invoice URL.
                      foreign_id:
                        type: string
                        description: This invoice's unique ID in your system.
                      end_user_reference:
                        type: string
                        description: >-
                          The unique ID of the customer this invoice is for. You
                          can use it to group invoices by customer.
                      address:
                        type: string
                        description: >-
                          The address that will receive the invoice payment. May
                          be null if address is not yet assigned.
                        example: 2N2xtaZCNygY3iq6XKPJsdoPMDX85LUc8SM
                      tag:
                        type: string
                        nullable: true
                        description: >-
                          Destination tag/memo. Present only for currencies that
                          support tags (e.g., XRP).
                      title:
                        type: string
                        minLength: 1
                        description: Invoice title.
                      status:
                        type: string
                        description: >-
                          For newly created invoices, this will always be either
                          `created` or `pending`.
                        enum:
                          - created
                          - pending
                      currency:
                        type: string
                        description: Invoice currency.
                      amount:
                        type: string
                        description: Invoice amount.
                        example: '0.01230000'
                      sender_currency:
                        type: string
                        default: null
                        description: >-
                          The currency the customer will pay in. Defaults to
                          null for invoices without a pre-selected currency.
                      sender_amount:
                        type: string
                        example: '0.01230000'
                        default: null
                        description: >-
                          The amount the customer needs to pay in their
                          sender_currency. Defaults to null for invoices without
                          a pre-selected currency.
                      fixed_at:
                        type: integer
                        format: int64
                        default: null
                        description: >-
                          The Unix timestamp for when the invoice was created,
                          in seconds. Defaults to null if no fixed payment quote
                          was created.
                      release_at:
                        type: integer
                        default: null
                        description: >-
                          The Unix timestamp for when the invoice will expire,
                          in seconds. Defaults to null for invoices without a
                          timer.
                        format: int64
                      seconds_left:
                        type: integer
                        format: int32
                        default: null
                        description: >-
                          The number of seconds left until the invoice expires.
                          Defaults to null for invoices without a timer.
                        example: 899
              examples:
                Invoice without a timer:
                  value:
                    data:
                      id: 826900
                      url: >-
                        https://invoices.sandbox.cryptoprocessing.com/invoice/Jyf1cQ
                      foreign_id: test_foreign_id_0344
                      end_user_reference: '12345'
                      address: null
                      title: Invoice Title
                      status: created
                      currency: EUR
                      amount: '100.00000000'
                      sender_currency: null
                      sender_amount: null
                      fixed_at: null
                      release_at: null
                      seconds_left: null
                Invoice with a timer:
                  value:
                    data:
                      id: 826904
                      url: >-
                        https://invoices.sandbox.cryptoprocessing.com/invoice/o6t4I8
                      foreign_id: test_foreign_id_0350
                      end_user_reference: '12345'
                      address: null
                      title: Invoice Title
                      status: pending
                      currency: EUR
                      amount: '100.00000000'
                      sender_currency: null
                      sender_amount: null
                      fixed_at: null
                      release_at: 1775177485
                      seconds_left: 59
                Invoice with a timer and a pre-selected currency:
                  value:
                    data:
                      id: 826906
                      url: >-
                        https://invoices.sandbox.cryptoprocessing.com/invoice/ZKeDtw
                      foreign_id: test_foreign_id_0351
                      end_user_reference: '12345'
                      address: tb1q0raamq6ppjpcfy5mzselzqfgcqaff59kt03lzl
                      title: Invoice Title
                      status: pending
                      currency: EUR
                      amount: '100.00000000'
                      sender_currency: BTC
                      sender_amount: '0.00129400'
                      fixed_at: 1775177497
                      release_at: 1775177557
                      seconds_left: 59
        '400':
          description: Bad Request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationOrMalformedJson'
              examples:
                Duplicate foreign_id:
                  summary: Foreign ID already used
                  value:
                    errors:
                      foreign_id: The foreign id has already been taken.
                Invalid currency:
                  summary: Currency not supported
                  value:
                    errors:
                      currency: The selected currency is invalid.
                Invalid amount:
                  summary: Amount validation failed
                  value:
                    errors:
                      amount: The amount must be a number.
                Amount below minimum:
                  summary: Amount below minimum limit
                  value:
                    errors:
                      amount: The amount must be at least 0.00010000 BTC.
                Invalid email:
                  summary: Invalid email format
                  value:
                    errors:
                      email_user: The email user must be a valid email address.
                Missing required fields:
                  summary: Required fields missing
                  value:
                    errors:
                      title: The title field is required.
                      foreign_id: The foreign id field is required.
                      currency: The currency field is required.
                      amount: The amount field is required.
                Invalid type:
                  summary: Invalid invoice type
                  value:
                    errors:
                      type: The selected type is invalid.
                Feature not enabled:
                  summary: Invoice feature is disabled
                  value:
                    message: Required features [invoices_enabled] not enabled.
                Malformed JSON:
                  summary: Invalid JSON body
                  value:
                    error: Bad content format
                    code: bad_content_format
        '403':
          $ref: '#/components/responses/HeaderAuthorization'
components:
  parameters:
    XProcessingSignatureHeader:
      name: X-Processing-Signature
      in: header
      required: true
      description: >-
        Hex-encoded HMAC-SHA512 signature of the request body, [generated using
        your secret key](/api-reference/authentication).
      schema:
        type: string
  schemas:
    end_user_reference:
      type: string
      description: >-
        A persistent internal user ID used to track all requests for the same
        end user. Must be consistent across requests and must not contain
        personal data, such as the user's name or email address. Put customer
        personal details in `sender_data`.
    sender_data_first_name:
      type: string
      maxLength: 255
      description: >-
        The sender's first name. This is required for a natural person. For a
        legal entity, do not include this parameter.
    sender_data_last_name:
      type: string
      maxLength: 255
      description: >-
        The sender's last name. This is required for a natural person. For a
        legal entity, do not include this parameter.
    sender_data_date_of_birth:
      type: string
      format: Y-m-d
      description: >-
        The sender's date of birth. For a legal entity, do not include this
        parameter.
    sender_data_legal_name:
      type: string
      description: >-
        The company's name. This is required for a legal entity. For a natural
        person, do not include this parameter.
    sender_data_country_of_registration:
      type: string
      description: >-
        The company's country of registration (ISO alpha-3 format, three
        characters). This is required for a legal entity. For a natural person,
        do not include this parameter.
    ValidationOrMalformedJson:
      oneOf:
        - type: object
          title: ValidationError
          description: One or more request parameters failed validation.
          properties:
            errors:
              type: object
              additionalProperties:
                type: string
        - type: object
          title: MalformedJson
          description: >-
            The request body is not valid JSON or the Content-Type header is not
            set to `application/json`.
          properties:
            error:
              type: string
            code:
              type: string
  responses:
    HeaderAuthorization:
      description: |
        Forbidden
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                description: Human-readable error message.
              code:
                type: string
                description: Error code.
            description: >-
              Invalid or missing headers. Refer to
              [Errors](/api-reference/errors#403) for troubleshooting steps.
          examples:
            Bad signature header:
              value:
                error: Bad signature header
                code: bad_header_signature
            No signature header:
              value:
                error: No signature header
                code: required_header_signature
            Bad key header:
              value:
                error: Bad key header
                code: bad_header_key
            No key header:
              value:
                error: No key header
                code: required_header_key
  securitySchemes:
    xProcessingKey:
      type: apiKey
      description: Your [API key](/integration-guide/get-your-api-key).
      in: header
      name: X-Processing-Key

````