---
title: "Create a charge treatment rule"
method: POST
path: "/companies/{company}/connected-accounts/{account}/charge-rules"
tags: ["Stripe"]
---

# Create a charge treatment rule

`POST /companies/{company}/connected-accounts/{account}/charge-rules`

## Request

- Base URL: `https://api.factuarea.com/v1`
- URL: `https://api.factuarea.com/v1/companies/{company}/connected-accounts/{account}/charge-rules`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-API-Key`

Creates a charge treatment rule at the end of the account's list; responds 201.
- A rule matches by `condition` and either invoices the charge or excludes it with `non_invoice_reason`.
- Fails with `charge_rule_invalid` or `charge_rule_limit_reached`.

## Path parameters

- `company` string, uuid, required
- `account` string, uuid, required

## Headers

- `Idempotency-Key` string
- `Factuarea-Version` string, date

## Request body

- ChargeRuleRequest
  - `condition` object, required
    - `type` 'metadata_equals' | 'description_contains' | 'payment_link', required
    - `key` string, nullable
    - `value` string, required
  - `outcome` 'invoice' | 'do_not_invoice', required
  - `concept` string, nullable
  - `vat_rate` number, nullable
  - `non_invoice_reason` 'indemnity_not_subject' | 'multipurpose_voucher' | 'invoiced_elsewhere' | 'null', nullable

## Response `201`

The newly created rule, placed at the end of the list.

- object
  - `data` ChargeRule, required: A charge treatment rule of a connected Stripe account. Rules are evaluated in `position` order and the first one that matches decides whether the charge is invoiced or left out. The public `id` is the rule UUID v7.
    - `id` string, uuid, required: UUID v7 of the rule. Public identity (KEY `id`).
    - `object` 'charge_rule', required: Stripe-like discriminator. Always `charge_rule`.
    - `position` integer, required: Evaluation order within the account, starting at 1. Change it with `PUT /v1/companies/{company}/connected-accounts/{account}/charge-rules/order`.
    - `condition` object, required: Condition a charge must meet for the rule to apply.
      - `type` 'metadata_equals' | 'description_contains' | 'payment_link', required: Kind of condition: the charge metadata `key` equals `value`, the charge description contains `value`, or the charge comes from the payment link `value`.
      - `key` string, nullable, required: Metadata key. Only used (and required) with `metadata_equals`; `null` otherwise.
      - `value` string, required: Value to compare against.
    - `outcome` 'invoice' | 'do_not_invoice', required: `invoice` issues the invoice (optionally with `concept` and `vat_rate`); `do_not_invoice` leaves the charge out and records it with `non_invoice_reason`.
    - `non_invoice_reason` 'indemnity_not_subject' | 'multipurpose_voucher' | 'invoiced_elsewhere' | 'null', nullable, required: Reason recorded for charges left out. Only with `do_not_invoice`; `null` with `invoice`.
    - `concept` string, nullable, required: Concept of the invoice line. Only with `invoice`; `null` otherwise.
    - `vat_rate` number, nullable, required: VAT rate in percent applied to the line. Only with `invoice`; `null` otherwise.
    - `created_at` string, date-time, required: When the rule was created (ISO 8601).
    - `updated_at` string, date-time, required: When the rule was last updated (ISO 8601).

## Other responses

- `400`: `parameter_unknown` with `subcode` `retired_active_profile_header`: the retired `X-Active-Profile` header was sent; the company goes in the path. `parameter_invalid_format` on `Factuarea-Version`: the header is not a `YYYY-MM-DD` date. `unsupported_api_version`: the `Factuarea-Version` date is not a supported version.
- `401`: Missing or invalid API key.
- `403`: The request is authenticated but not allowed: the API key lacks the required scope (`insufficient_scope`), the plan does not include the public API or this feature (`addon_not_active`, `feature_not_available_in_plan`), or the module is not available with a test key (`module_not_available_in_sandbox`). `company_inactive`: the company in the path is deactivated; reactivate it to operate.
- `404`: The requested resource does not exist or belongs to another company. `profile_not_found`: the company in the path does not exist, is not in the API key scope or belongs to the other environment (live or test).
- `422`: Validation failed. The `error.param` field identifies which input is invalid. `idempotency_key_reused`: the `Idempotency-Key` was already used with a different body; send a new key or the same body. `invalid_param_format` on `Idempotency-Key`: the key must be 1 to 255 printable ASCII characters.
- `429`: Rate limit exceeded. Retry after the duration in `Retry-After`.
- `500`: Unexpected server error.

---

[API](https://skmtc.dev/factuarea/apis/factuarea-public-api.md) · [All operations](https://skmtc.dev/factuarea/apis/factuarea-public-api/llms.txt) · [OpenAPI document](https://skmtc.dev/factuarea/apis/factuarea-public-api/revisions/718e77934422?raw)
