> For the complete documentation index, see [llms.txt](https://docs.4p.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.4p.finance/en/on-ramp/creating-a-transaction.md).

# Creating a transaction

### Service

* Sends a JSON containing the data required to create an instant charge.
* Returns a JSON containing the data of the created charge, including the Pix Copy-and-Paste code.

### Registration/transaction request

The request to create/register a transaction must have, as the JSON request body, the information required to register the transaction.

### Payload example

```json
{
  "cpf": "01234567899", // Change this key to "cnpj" for a legal entity / CNPJ.
  "email": "user@example.com",
  "amount": 1.10,
  "expires": 3600,
  "custom_id": "PN123",
  "custom_data": {
    "chain": "Arbitrum", // Optional (Default: Arbitrum)
    "asset": "USDT", // Optional (Default: USDT)
    "receiver_wallet": "0x4328...edFB995B6I"
  },
  "description": "Subscription charge #PN123",
  "notification_url": "https://your-webhook-domain.com/param=tes&token=abcd-dfg"
}
```

### Request

Requests the creation/registration of a transaction.

**PUT** `https://api.4p.finance/v1/pix/transaction`

Submits the request to register a transaction.

#### Headers

| Name        | Type   | Description   |
| ----------- | ------ | ------------- |
| x-api-key\* | String | Your API key. |

#### Request Body

| Name                 | Type    | Description                                                                                                                                                                                      |
| -------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| expires\*            | Integer | Lifetime of the charge, in seconds, starting from the creation date. Must be equal to or greater than 300. Maximum: 259200 seconds.                                                              |
| amount\*             | Number  | Original amount of the charge. Must be a value greater than or equal to 0.01, with decimal places.                                                                                               |
| custom\_id \*        | String  | Transaction Id or Pix Id. Allows the receiving user to reconcile payments. Must be unique per Pix transaction and contain a maximum of 255 characters.                                           |
| description\*        | String  | Represents a text (the Pix *solicitacaoPagador* field) to be shown to the paying user so they can enter related, free-form information to be sent to the receiving user. Maximum 140 characters. |
| notification\_url \* | String  | URL that will receive the POST notifications sent by the webhook service right after the Pix payment is made.                                                                                    |
| custom\_data\*       | Object  | Parent object for custom data.                                                                                                                                                                   |
| receiver\_wallet\*   | String  | Child key of *custom\_data* used to send the wallet of the customer paying via Pix, which will receive the cryptocurrency. Used for cryptocurrency purchases through the PIX API (P2P).          |

{% tabs %}
{% tab title="200: OK Response after creating/registering a transaction." %}

```json
{
    "http_code": 200,
    "success": true,
    "info": {
        "result": "pix_transaction_created",
        "message": "The Pix transaction was successfully created.",
        "data": {
            "calendario": {
                "criacao": "2026-01-01T11:05:53.009Z",
                "expiracao": 3600
            },
            "devedor": {
                "cnpj": "00000000000000",
                "nome": ""
            },
            "valor": {
                "modalidadeAlteracao": 0,
                "original": 1.1
            },
            "chave": "4cf1bb22-71c1-4530-b735-d240c3c0f88a",
            "solicitacaoPagador": "Subscription charge #PN123",
            "infoAdicionais": [],
            "txid": "2ce3608c77264388b956c039",
            "location": "brcode.infra.com/v2/8657085674d44db288430cftb155ca62",
            "revisao": 0,
            "status": "ATIVA",
            "pixCopiaECola": "00010301021226190014br.gov.bcb.pix2557brcode.infra.com/v2/1652085674d33db965430cfab255ba405204000053039865802BR59254Pay Finance Prestadora d6106Recife62070503***6304F9E1",
            "code": 201
        }
    }
}
```

{% endtab %}
{% endtabs %}

### Response

Note that the *data* object contains the Pix data, including the Copy-and-Paste key (`pixCopiaECola`). When creating a Pix charge, the receiving user gets the information needed to generate the dynamic QR Code image, along with its representation as a Pix Copy-and-Paste code.

Please note that the QR Code image itself is not generated by the API — that is left up to each implementer.

### Conclusion

After the payment is confirmed, the amount converted into cryptocurrency will be automatically sent to the wallet provided in the request payload.

The average time to send and finalize the transaction is approximately 10 seconds, and may vary depending on the selected blockchain network and that network's conditions at the time of the operation.

Learn more about notifications and callbacks in the next section.
