> For the complete documentation index, see [llms.txt](https://developers.rewardful.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.rewardful.com/rest-api/sales/create-sale.md).

# Create sale

This endpoint allows merchants to create records of sales directly in Rewardful.

## Request

| Method | URL                                     |
| ------ | --------------------------------------- |
| `POST` | `https://api.getrewardful.com/v1/sales` |

### Parameters

| Parameter             | Required? | Description                                            |
| --------------------- | --------- | ------------------------------------------------------ |
| `currency`            | yes       | ISO currency code in which the sale is denominated     |
| `charged_at`          | yes       | Time at which the sale was charged                     |
| `invoiced_at`         | yes       | Time at which the sale was invoiced                    |
| `label`               | no        | Description of the sale (e.g. name of the product)     |
| `external_id`         | yes       | The technical ID of the sale as in the merchant system |
| `charge_amount_cents` | yes       | The charged amount of the sale, in cents               |
| `refund_amount_cents` | yes       | The refunded amount of the sale, in cents              |
| `tax_amount_cents`    | yes       | The tax amount of the sale, in cents                   |
| `referral_id`         | yes       | ID of the existing referral who made the purchase      |

### Example

```bash
curl --request POST \
  --url https://api.getrewardful.com/v1/sales \
  -u YOUR_API_SECRET: \
  -d "label=Super sale" \
  -d charged_at=2020-10-18T16:13:12.109Z \
  -d invoiced_at=2020-10-18T16:13:12.109Z \
  -d currency=USD \
  -d external_id=abc-123 \
  -d charge_amount_cents=5000 \
  -d refund_amount_cents=0 \
  -d tax_amount_cents=0 \
  -d referral_id=d154e622-278a-4103-b191-5cbebae4047a
```

## Response

{% tabs %}
{% tab title="Success" %}

| Response code | Body                 |
| ------------- | -------------------- |
| 200           | A sale object (JSON) |
| {% endtab %}  |                      |

{% tab title="Failures" %}

#### Invalid parameters

| Response code | Body                                      |
| ------------- | ----------------------------------------- |
| `422`         | JSON object describing validation errors. |

```javascript
{
  "error": "Could not create sale.",
  "details": ["Charged at can't be blank"]
}
```

#### Authentication failure

| Response code | Body                                       |
| ------------- | ------------------------------------------ |
| `401`         | Description of the authentication failure. |

```javascript
{  "error": "Invalid API Secret." }
```

{% endtab %}
{% endtabs %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.rewardful.com/rest-api/sales/create-sale.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
