> 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"
    },
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pay-apidocs.fizen.io/reference/api-reference/charges/create-a-charge.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
