# Update commission

{% hint style="warning" %}
**Note:** While still supported, this is no longer the preferred method for marking a commission as paid.  For that, use the [Mark a payout as paid](/rest-api/payouts/mark-a-payout-as-paid.md) method, which allows you to mark a batch of commissions for a single affiliate as paid with a single API call.
{% endhint %}

## Request

| Method | URL                                               |
| ------ | ------------------------------------------------- |
| `PUT`  | `https://api.getrewardful.com/v1/commissions/:id` |

### Parameters

| Parameter | Description                                                                                                                                                                                                                   |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `paid_at` | Timestamp (as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) formatted string) representing when this commission was paid. Can be any time in the past/future.                                                         |
| `due_at`  | Timestamp (as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) formatted string) indicating when this commission should be considered payable to the affiliate. Can be any time in the past/future, but cannot be blank. |

### Examples

#### Mark a commission as paid

```bash
curl --request PUT \
  --url https://api.getrewardful.com/v1/commissions/01342824-914a-4aee-9f42-de823a8b74e2 \
  --data paid_at=2020-08-23T20:37:59.256Z
  -u YOUR_API_SECRET:
```

#### Mark a commission as unpaid

```bash
curl --request PUT \
  --url https://api.getrewardful.com/v1/commissions/01342824-914a-4aee-9f42-de823a8b74e2 \
  --data paid_at=
  -u YOUR_API_SECRET:
```

#### Change the due date of a commission

```bash
curl --request PUT \
  --url https://api.getrewardful.com/v1/commissions/01342824-914a-4aee-9f42-de823a8b74e2 \
  --data due_at=2020-08-23T20:37:59.256Z
  -u YOUR_API_SECRET:
```

## Response

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

| Response code | Body                                                                                                              |
| ------------- | ----------------------------------------------------------------------------------------------------------------- |
| `200`         | JSON object describing the updated [commission](https://developers.getrewardful.com/rest-api/commissions/object). |

```javascript
{
  "id": "39e68c88-d84a-4510-b3b4-43c75016a080",
  "created_at": "2020-08-19T16:28:31.164Z",
  "updated_at": "2020-08-19T16:28:31.164Z",
  "amount": 3000,
  "currency": "USD",
  "due_at": "2020-09-18T16:28:25.000Z",
  "paid_at": null,
  "campaign": {
    "id": "c3482343-8680-40c5-af9a-9efa119713b5",
    "created_at": "2020-05-22T02:55:19.802Z",
    "updated_at": "2020-08-19T16:28:16.177Z",
    "name": "Friends Of MI6"
  },
  "sale": {
    "id": "74e37d3b-03c5-4bfc-841c-a79d5799551a",
    "currency": "USD",
    "charged_at": "2020-08-19T16:28:25.000Z",
    "stripe_account_id": "acct_ABC123",
    "stripe_charge_id": "ch_ABC123",
    "invoiced_at": "2020-08-19T16:28:25.000Z",
    "created_at": "2020-08-19T16:28:31.102Z",
    "updated_at": "2020-08-19T16:28:31.102Z",
    "charge_amount_cents": 10000,
    "refund_amount_cents": 0,
    "tax_amount_cents": 0,
    "sale_amount_cents": 10000,
    "referral": {
      "id": "d154e622-278a-4103-b191-5cbebae4047a",
      "stripe_account_id": "acct_ABC123",
      "stripe_customer_id": "cus_ABC123",
      "conversion_state": "conversion",
      "deactivated_at": null,
      "expires_at": "2020-10-18T16:13:12.109Z",
      "created_at": "2020-08-19T16:13:12.109Z",
      "updated_at": "2020-08-19T16:28:31.166Z",
      "customer": {
        "platform": "stripe",
        "id": "cus_ABC123",
        "name": "Freddie Mercury",
        "email": "freddie@example.com"
      },
      "visits": 2,
      "link": {
        "id": "b759a9ed-ed63-499f-b621-0221f2712086",
        "url": "http://www.demo.com:8080/?via=james",
        "token": "james",
        "visitors": 197,
        "leads": 196,
        "conversions": 156
      }
    },
    "affiliate": {
      "id": "07d8acc5-c689-4b4a-bbab-f88a71ffc012",
      "created_at": "2020-05-22T02:55:19.934Z",
      "updated_at": "2020-08-19T16:28:31.168Z",
      "first_name": "James",
      "last_name": "Bond",
      "email": "jb007@mi.co.uk",
      "paypal_email": "",
      "confirmed_at": "2020-07-09T03:53:06.760Z",
      "paypal_email_confirmed_at": "2020-07-03T17:49:23.489Z",
      "receive_new_commission_notifications": true,
      "sign_in_count": 1,
      "unconfirmed_email": null,
      "stripe_customer_id": null,
      "stripe_account_id": null,
      "visitors": 197,
      "leads": 196,
      "conversions": 156,
      "campaign": {
        "id": "c3482343-8680-40c5-af9a-9efa119713b5",
        "created_at": "2020-05-22T02:55:19.802Z",
        "updated_at": "2020-08-19T16:28:16.177Z",
        "name": "Friends Of MI6"
      }
    }
  }
}
```

{% endtab %}

{% tab title="Failure" %}

### Invalid parameters

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

```javascript
{
  "error": "Could not update commission.",
  "details": [
    "Due 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: 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://developers.rewardful.com/rest-api/commissions/update.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.
