> For the complete documentation index, see [llms.txt](https://docs.explodely.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.explodely.com/api/create-affiliate-referral-contract.md).

# Create Affiliate Referral Contract

Affiliate API Endpoint:

`https://explodely.com/api/v1/aff`&#x20;

Parameters:

To create an affiliate referral contract (second tier affiliate contract), you need to send below parameters as POST to the affiliate API endpoint.

username - Your Explodely account username

apikey - Your Explodely account API key

apiaction - This should always be set as "createaffcontract"

contract\_name - Contract name (for your records)

partner\_username - Explodely affiliate ID of the partner

product - Either Explodely product ID for which contract needs to be made or "allproducts"

commission - Up to 80, the percentage of your share the partner will get

start\_date - Start date in format dd-mmm-yyyy (01-jan-2024), optional (default: starts right away)

end\_date - End date in format dd-mmm-yyyy (31-jan-2024), optional (default: active unless terminated)

max\_earnings - value of contract sales after which the contract will expire, optional

max\_sales - number of contract sales after which the contract will expire, optional

comments  - Comments visible inside Explodely seller contracts section, optional

activate - Activate contract immediately if set as yes, optional (default no)

mutual\_termination - If set as yes, the contract terminates after both partner approval, optional (default yes)

Responses:

The API endpoint returns a JSON object.

`{"error":"invalidapikey"}` - This is returned when the API key and username is not authenticated.

`{"error":"invalid_partnerusername"}` - This is returned when the provided partner\_username is not a valid Explodely affiliate account.

`{"error":"partner_contract_exists"}` - This is returned when an active contract with partner username already exists.

`{"error":"`duplicate\_contract`"}` - This is returned when the contract is already there.

`{"error":"`contract\_exists`"}` - This is returned when the contract for all products already exists.

`{"error":"`commission\_limit\_exceeded`"}` - This is returned when the percentage of your share for all contracts exceeds 80%

`{"error":"`failed`"}` - This is returned when the contract creation has failed.

`{"`contract\_created`":"ok", "contractid ":"12345"}` - This is returned when the contract has been created where 12345 would be replaced with contract ID of the actual contract which you can use later in other API requests.


---

# 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://docs.explodely.com/api/create-affiliate-referral-contract.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.
