# Invoice a customer of the business

`POST /payments/invoice-customer` · Rivier · shop

Invoice a customer of the business: the invoice is made and finalised through the invoices module (its number, its lines, its rules) and, if asked, gets a payment link on the business's own Stripe account for the total. An agent works inside the limits the owner set for payment requests: an invoice over the amount cap, in another currency or for a customer outside the list waits for the owner, and the draft stays until it is approved.

- Scope: shop:write
- Mcp: rivier_payments_invoice_customer
- Graphql: Mutation.shopInvoiceCustomerCreate
- Sdk: shop.invoiceCustomer.create
- Cli: shop invoice customer create

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "currency": {
      "type": "string",
      "pattern": "^[A-Za-z]{3}$"
    },
    "contact": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "email": {
          "type": "string",
          "format": "email",
          "maxLength": 254
        },
        "addressLines": {
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 200
          },
          "maxItems": 6,
          "default": []
        },
        "country": {
          "type": "string",
          "pattern": "^[A-Z]{2}$"
        },
        "vatId": {
          "type": "string",
          "maxLength": 30
        },
        "registration": {
          "type": "string",
          "maxLength": 60
        },
        "city": {
          "type": "string",
          "maxLength": 100
        },
        "postalCode": {
          "type": "string",
          "maxLength": 20
        },
        "endpointScheme": {
          "type": "string",
          "pattern": "^[0-9A-Z]{4}$"
        },
        "endpointId": {
          "type": "string",
          "pattern": "^\\S(.{0,48}\\S)?$"
        },
        "paymentAccount": {
          "type": "string",
          "pattern": "^[A-Za-z0-9 ]{4,42}$"
        },
        "paymentBic": {
          "type": "string",
          "pattern": "^[A-Za-z0-9]{8,11}$"
        },
        "language": {
          "type": "string",
          "pattern": "^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$",
          "maxLength": 20
        }
      },
      "required": [
        "name"
      ],
      "additionalProperties": false
    },
    "dueDate": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "issueDate": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "supplyDate": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "notes": {
      "type": "string",
      "maxLength": 2000,
      "default": ""
    },
    "paymentTerms": {
      "type": "string",
      "maxLength": 500
    },
    "reference": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "maxLength": 40
        },
        "id": {
          "type": "string",
          "maxLength": 120
        }
      },
      "required": [
        "kind",
        "id"
      ],
      "additionalProperties": false
    },
    "lines": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "quantity": {
            "type": "number",
            "exclusiveMinimum": 0,
            "maximum": 1000000,
            "default": 1
          },
          "unit": {
            "type": "string",
            "maxLength": 10,
            "default": "C62"
          },
          "unitAmountMinor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 99999999999
          },
          "discountMinor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 99999999999,
            "default": 0
          },
          "taxRateBp": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000
          },
          "taxCategory": {
            "type": "string",
            "enum": [
              "S",
              "Z",
              "E",
              "AE",
              "K",
              "G",
              "O",
              "L",
              "M"
            ],
            "default": "S"
          },
          "productId": {
            "type": "string",
            "format": "uuid"
          },
          "source": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "maxLength": 40
              },
              "id": {
                "type": "string",
                "maxLength": 120
              }
            },
            "required": [
              "kind",
              "id"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "description",
          "unitAmountMinor"
        ],
        "additionalProperties": false
      },
      "minItems": 1,
      "maxItems": 50
    },
    "requestPayment": {
      "type": "boolean",
      "default": true
    },
    "idempotencyKey": {
      "type": "string",
      "minLength": 8,
      "maxLength": 100
    }
  },
  "required": [
    "currency",
    "contact",
    "lines",
    "idempotencyKey"
  ],
  "additionalProperties": false
}
```

## Responses

- `200`: Success
- `400`: The request was malformed
- `401`: No valid credential
- `403`: The credential lacks the scope, origin or address
- `429`: Over the key's rate limit; see Retry-After

## Example

```sh
curl -X POST 'https://api.rivier.ai/payments/invoice-customer' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "currency": "string",
  "contact": {
    "name": "string"
  },
  "lines": [
    {
      "description": "string",
      "unitAmountMinor": 0
    }
  ],
  "idempotencyKey": "string"
}'
```
