> For the complete documentation index, see [llms.txt](https://pay-apidocs.fizen.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pay-apidocs.fizen.io/reference/api-reference/charges/create-a-charge.md).

# Create a charge

## Create a charge

<mark style="color:green;">`POST`</mark> `/charges`

#### Request Body

| Name                                         | Type   | Description                                                        |
| -------------------------------------------- | ------ | ------------------------------------------------------------------ |
| name                                         | string | Charge name                                                        |
| description                                  | string | Charge description                                                 |
| logoUrl                                      | string | Charge image URL                                                   |
| localPrice<mark style="color:red;">\*</mark> | Object | <p>amount: Charge amount</p><p>currency: Charge local currency</p> |
| metadata                                     | any    | Self defined metadata                                              |
| redirectUrl                                  | string | Redirect URL                                                       |
| cancelUrl                                    | string | Cancel URL                                                         |

{% tabs %}
{% tab title="201: Created Charge is created successfully" %}

```javascript
{
    "statusCode": 201,
    "time": "2022-01-12T16:32:37.178Z",
    "data": {
        "code": "_PM3TX-7nVNY4K1pDqz8u",
        "hostedUrl": "https://payment.fizen.io/commerce/charges/_PM3TX-7nVNY4K1pDqz8u"
    },
}
```

{% endtab %}

{% tab title="401: Unauthorized Request is unauthorized" %}

```javascript
{
    "statusCode": 401,
    "message": "Unauthorized"
}
```

{% endtab %}
{% endtabs %}

#### Example request:

```
curl --location --request POST 'https://pay-api.fizen.io/api/integration/v1/charges' \
--header 'X-FP-API-KEY: 7abd3993-daf7-4322-84c6-c86e04b3d884' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "Charge name",
    "description": "Charge description",
    "localPrice": {
        "amount": 100,
        "currency": "USD"
    },
    "metadata": {
        "orderId": "order-id1",
        "orderKey": "key1",
        "source": "some-ecommerce"
    },
    "logoUrl": "https://logo-url.com/image.png",
    "redirectUrl": "https://ecommerce-endpoint.com/redirect-url",
    "cancelUrl": "https://ecommerce-endpoint.com/cancel-url"
}'
```

#### Example response:

```
{
    "statusCode": 201,
    "time": "2022-01-12T16:32:37.178Z",
    "data": {
        "code": "OST1FNY35QDL",
        "hostedUrl": "https://payment.fizen.io/commerce/charges/OST1FNY35QDL"
    },
}
```
