> 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/affiliates/create.md).

# Create affiliate

Creates a new affiliate in your account with the specified parameters.

This endpoint allows merchants to create affiliates on demand.

Both normal affiliates and customer referrers can be created through this endpoint. To create a customer referrer, simply pass the `stripe_customer_id` parameter that indicates the Stripe Customer that should receive account credits as rewards.

{% hint style="info" %}
Rewardful does not send a "Welcome Email" or require email confirmation for affiliates created through the REST API. If you would like to send a "Welcome Email" to these affiliates, you can do so from your application after making the API call, respond to the [`affiliate.created` webhook](https://developers.getrewardful.com/webhooks/event-types#affiliates), or configure on of our [email integrations](https://help.getrewardful.com/en/collections/2290354-email-integrations-webhooks).
{% endhint %}

## Request

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

### Parameters

| Parameter            | Required? | Description                                                                                                                                                                       |
| -------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `first_name`         | Yes       | The affiliate's first name.                                                                                                                                                       |
| `last_name`          | Yes       | The affiliate's last name.                                                                                                                                                        |
| `email`              | Yes       | The affiliate's email address.                                                                                                                                                    |
| `state`              | No        | A string indicating the [affiliate's state](/rest-api/affiliates/object.md#state). Defaults to `active`.                                                                          |
| `stripe_customer_id` | No        | For customer referral programs, this is the Stripe Customer that will receive account credits as rewards. ***Note:** the customer must exist in your Stripe account in livemode.* |
| `token`              | No        | Alphanumeric code to be used for links, ex: `?via=token` Must contain only letters, numbers, and dashes.                                                                          |
| `campaign_id`        | No        | <p>The UUID of the campaign this affiliate should be added to. Affiliate will be added to your default campaign if this parameter is </p><p>blank.</p>                            |
| `paypal_email`       | No        | The PayPal address that commissions should be paid to.                                                                                                                            |
| `wise_email`         | No        | The Wise address that commissions should be paid to.                                                                                                                              |

`receive_new_commission_notifications` may also be optionally provided. This parameter indicates whether or not the affiliate should receive emails when new rewards and commissions are earned. Accepts `true` (default) or `false`.

### Example

```bash
curl --request POST \
  --url https://api.getrewardful.com/v1/affiliates \
  -u YOUR_API_SECRET: \
  -d first_name=James \
  -d last_name=Bond \
  -d email=jb007@mi6.co.uk \
  -d token=jb007 \
  -d stripe_customer_id=cus_ABC123
```

## Response

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

| Response code | Body                                                         |
| ------------- | ------------------------------------------------------------ |
| 200           | An [affiliate object](/rest-api/affiliates/object.md) (JSON) |
| {% endtab %}  |                                                              |

{% tab title="Failures" %}

### Invalid parameters

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

```javascript
{
  "error": "Could not create affiliate.",
  "details": ["Email 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/affiliates/create.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.
