Create an affiliate
Creates an affiliate in your account and runs your Affiliate created triggers (for example, webhooks). The new affiliate is not added to any program; use Add an affiliate to a program for that. The id is derived from the first and last name, with a number appended if it is taken. If the name leaves fewer than three characters once converted to Latin letters and digits, the id is random instead, so read it from the response.
If you omit password, a temporary password is generated and returned once in the password field, and the affiliate must change it at first login. The address is saved only when address, postal_code, city and country.code are all present; otherwise it is silently dropped.
custom_fields keys must match your signup form’s custom fields. An unknown key returns 400 Not a valid property '...'. Required custom fields are checked only when you send custom_fields: a missing one then returns 400 Property '...' is required, naming the field’s title. Invalid names or email also return 400, for example Please enter a first name or This value is not a valid email address.
curl --request POST \
--url https://api.tapfiliate.com/1.6/affiliates/ \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--data '
{
"firstname": "Ramone",
"lastname": "Referra",
"email": "ramona@referra.com",
"password": "password1234",
"company": {
"name": "Referra Inc.",
"description": "Best referrer ever"
},
"address": {
"address": "Rapenburgerstraat 173",
"address_two": null,
"postal_code": "1011 VM",
"city": "Amsterdam",
"state": "Noord-Holland",
"country": {
"code": "NL"
}
},
"custom_fields": {
"field1": "value1"
}
}
'const options = {
method: 'POST',
headers: {'X-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
firstname: 'Ramone',
lastname: 'Referra',
email: 'ramona@referra.com',
password: 'password1234',
company: {name: 'Referra Inc.', description: 'Best referrer ever'},
address: {
address: 'Rapenburgerstraat 173',
address_two: null,
postal_code: '1011 VM',
city: 'Amsterdam',
state: 'Noord-Holland',
country: {code: 'NL'}
},
custom_fields: {field1: 'value1'}
})
};
fetch('https://api.tapfiliate.com/1.6/affiliates/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.tapfiliate.com/1.6/affiliates/"
payload = {
"firstname": "Ramone",
"lastname": "Referra",
"email": "ramona@referra.com",
"password": "password1234",
"company": {
"name": "Referra Inc.",
"description": "Best referrer ever"
},
"address": {
"address": "Rapenburgerstraat 173",
"address_two": None,
"postal_code": "1011 VM",
"city": "Amsterdam",
"state": "Noord-Holland",
"country": { "code": "NL" }
},
"custom_fields": { "field1": "value1" }
}
headers = {
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tapfiliate.com/1.6/affiliates/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'firstname' => 'Ramone',
'lastname' => 'Referra',
'email' => 'ramona@referra.com',
'password' => 'password1234',
'company' => [
'name' => 'Referra Inc.',
'description' => 'Best referrer ever'
],
'address' => [
'address' => 'Rapenburgerstraat 173',
'address_two' => null,
'postal_code' => '1011 VM',
'city' => 'Amsterdam',
'state' => 'Noord-Holland',
'country' => [
'code' => 'NL'
]
],
'custom_fields' => [
'field1' => 'value1'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api.tapfiliate.com/1.6/affiliates/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"firstname\": \"Ramone\",\n \"lastname\": \"Referra\",\n \"email\": \"ramona@referra.com\",\n \"password\": \"password1234\",\n \"company\": {\n \"name\": \"Referra Inc.\",\n \"description\": \"Best referrer ever\"\n },\n \"address\": {\n \"address\": \"Rapenburgerstraat 173\",\n \"address_two\": null,\n \"postal_code\": \"1011 VM\",\n \"city\": \"Amsterdam\",\n \"state\": \"Noord-Holland\",\n \"country\": {\n \"code\": \"NL\"\n }\n },\n \"custom_fields\": {\n \"field1\": \"value1\"\n }\n}"
response = http.request(request)
puts response.read_bodypackage main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tapfiliate.com/1.6/affiliates/"
payload := strings.NewReader("{\n \"firstname\": \"Ramone\",\n \"lastname\": \"Referra\",\n \"email\": \"ramona@referra.com\",\n \"password\": \"password1234\",\n \"company\": {\n \"name\": \"Referra Inc.\",\n \"description\": \"Best referrer ever\"\n },\n \"address\": {\n \"address\": \"Rapenburgerstraat 173\",\n \"address_two\": null,\n \"postal_code\": \"1011 VM\",\n \"city\": \"Amsterdam\",\n \"state\": \"Noord-Holland\",\n \"country\": {\n \"code\": \"NL\"\n }\n },\n \"custom_fields\": {\n \"field1\": \"value1\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.tapfiliate.com/1.6/affiliates/")
.header("X-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"firstname\": \"Ramone\",\n \"lastname\": \"Referra\",\n \"email\": \"ramona@referra.com\",\n \"password\": \"password1234\",\n \"company\": {\n \"name\": \"Referra Inc.\",\n \"description\": \"Best referrer ever\"\n },\n \"address\": {\n \"address\": \"Rapenburgerstraat 173\",\n \"address_two\": null,\n \"postal_code\": \"1011 VM\",\n \"city\": \"Amsterdam\",\n \"state\": \"Noord-Holland\",\n \"country\": {\n \"code\": \"NL\"\n }\n },\n \"custom_fields\": {\n \"field1\": \"value1\"\n }\n}")
.asString();This response has no body data.{
"errors": [
{
"message": "Missing mandatory parameter(s)"
}
]
}{
"message": "Authentication Failed.",
"code": 401
}{
"message": "Forbidden",
"code": 403,
"traceId": "04ed655728a22bc0d39f"
}curl --request POST \
--url https://api.tapfiliate.com/1.6/affiliates/ \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--data '
{
"firstname": "Ramone",
"lastname": "Referra",
"email": "ramona@referra.com",
"password": "password1234",
"company": {
"name": "Referra Inc.",
"description": "Best referrer ever"
},
"address": {
"address": "Rapenburgerstraat 173",
"address_two": null,
"postal_code": "1011 VM",
"city": "Amsterdam",
"state": "Noord-Holland",
"country": {
"code": "NL"
}
},
"custom_fields": {
"field1": "value1"
}
}
'const options = {
method: 'POST',
headers: {'X-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
firstname: 'Ramone',
lastname: 'Referra',
email: 'ramona@referra.com',
password: 'password1234',
company: {name: 'Referra Inc.', description: 'Best referrer ever'},
address: {
address: 'Rapenburgerstraat 173',
address_two: null,
postal_code: '1011 VM',
city: 'Amsterdam',
state: 'Noord-Holland',
country: {code: 'NL'}
},
custom_fields: {field1: 'value1'}
})
};
fetch('https://api.tapfiliate.com/1.6/affiliates/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.tapfiliate.com/1.6/affiliates/"
payload = {
"firstname": "Ramone",
"lastname": "Referra",
"email": "ramona@referra.com",
"password": "password1234",
"company": {
"name": "Referra Inc.",
"description": "Best referrer ever"
},
"address": {
"address": "Rapenburgerstraat 173",
"address_two": None,
"postal_code": "1011 VM",
"city": "Amsterdam",
"state": "Noord-Holland",
"country": { "code": "NL" }
},
"custom_fields": { "field1": "value1" }
}
headers = {
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tapfiliate.com/1.6/affiliates/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'firstname' => 'Ramone',
'lastname' => 'Referra',
'email' => 'ramona@referra.com',
'password' => 'password1234',
'company' => [
'name' => 'Referra Inc.',
'description' => 'Best referrer ever'
],
'address' => [
'address' => 'Rapenburgerstraat 173',
'address_two' => null,
'postal_code' => '1011 VM',
'city' => 'Amsterdam',
'state' => 'Noord-Holland',
'country' => [
'code' => 'NL'
]
],
'custom_fields' => [
'field1' => 'value1'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api.tapfiliate.com/1.6/affiliates/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"firstname\": \"Ramone\",\n \"lastname\": \"Referra\",\n \"email\": \"ramona@referra.com\",\n \"password\": \"password1234\",\n \"company\": {\n \"name\": \"Referra Inc.\",\n \"description\": \"Best referrer ever\"\n },\n \"address\": {\n \"address\": \"Rapenburgerstraat 173\",\n \"address_two\": null,\n \"postal_code\": \"1011 VM\",\n \"city\": \"Amsterdam\",\n \"state\": \"Noord-Holland\",\n \"country\": {\n \"code\": \"NL\"\n }\n },\n \"custom_fields\": {\n \"field1\": \"value1\"\n }\n}"
response = http.request(request)
puts response.read_bodypackage main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tapfiliate.com/1.6/affiliates/"
payload := strings.NewReader("{\n \"firstname\": \"Ramone\",\n \"lastname\": \"Referra\",\n \"email\": \"ramona@referra.com\",\n \"password\": \"password1234\",\n \"company\": {\n \"name\": \"Referra Inc.\",\n \"description\": \"Best referrer ever\"\n },\n \"address\": {\n \"address\": \"Rapenburgerstraat 173\",\n \"address_two\": null,\n \"postal_code\": \"1011 VM\",\n \"city\": \"Amsterdam\",\n \"state\": \"Noord-Holland\",\n \"country\": {\n \"code\": \"NL\"\n }\n },\n \"custom_fields\": {\n \"field1\": \"value1\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.tapfiliate.com/1.6/affiliates/")
.header("X-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"firstname\": \"Ramone\",\n \"lastname\": \"Referra\",\n \"email\": \"ramona@referra.com\",\n \"password\": \"password1234\",\n \"company\": {\n \"name\": \"Referra Inc.\",\n \"description\": \"Best referrer ever\"\n },\n \"address\": {\n \"address\": \"Rapenburgerstraat 173\",\n \"address_two\": null,\n \"postal_code\": \"1011 VM\",\n \"city\": \"Amsterdam\",\n \"state\": \"Noord-Holland\",\n \"country\": {\n \"code\": \"NL\"\n }\n },\n \"custom_fields\": {\n \"field1\": \"value1\"\n }\n}")
.asString();This response has no body data.{
"errors": [
{
"message": "Missing mandatory parameter(s)"
}
]
}{
"message": "Authentication Failed.",
"code": 401
}{
"message": "Forbidden",
"code": 403,
"traceId": "04ed655728a22bc0d39f"
}