curl --request POST \
--url https://development.knotapi.com/zero-link/batch/create \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "card_switcher",
"users": [
{
"phone_number": "+12025550123",
"external_user_id": "123abc",
"card_id": "81n9al10a0ayn13"
},
{
"phone_number": "+12025550124",
"external_user_id": "456def",
"card_id": "92o0bm21b1bzo24"
},
{
"phone_number": "1234567892",
"external_user_id": "789ghi",
"card_id": "03p1cn32c2c0p35"
},
{
"phone_number": "+12025550125",
"external_user_id": "123abc",
"card_id": "81n9al10a0ayn13"
}
]
}
'import requests
url = "https://development.knotapi.com/zero-link/batch/create"
payload = {
"type": "card_switcher",
"users": [
{
"phone_number": "+12025550123",
"external_user_id": "123abc",
"card_id": "81n9al10a0ayn13"
},
{
"phone_number": "+12025550124",
"external_user_id": "456def",
"card_id": "92o0bm21b1bzo24"
},
{
"phone_number": "1234567892",
"external_user_id": "789ghi",
"card_id": "03p1cn32c2c0p35"
},
{
"phone_number": "+12025550125",
"external_user_id": "123abc",
"card_id": "81n9al10a0ayn13"
}
]
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
type: 'card_switcher',
users: [
{
phone_number: '+12025550123',
external_user_id: '123abc',
card_id: '81n9al10a0ayn13'
},
{
phone_number: '+12025550124',
external_user_id: '456def',
card_id: '92o0bm21b1bzo24'
},
{
phone_number: '1234567892',
external_user_id: '789ghi',
card_id: '03p1cn32c2c0p35'
},
{
phone_number: '+12025550125',
external_user_id: '123abc',
card_id: '81n9al10a0ayn13'
}
]
})
};
fetch('https://development.knotapi.com/zero-link/batch/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://development.knotapi.com/zero-link/batch/create",
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([
'type' => 'card_switcher',
'users' => [
[
'phone_number' => '+12025550123',
'external_user_id' => '123abc',
'card_id' => '81n9al10a0ayn13'
],
[
'phone_number' => '+12025550124',
'external_user_id' => '456def',
'card_id' => '92o0bm21b1bzo24'
],
[
'phone_number' => '1234567892',
'external_user_id' => '789ghi',
'card_id' => '03p1cn32c2c0p35'
],
[
'phone_number' => '+12025550125',
'external_user_id' => '123abc',
'card_id' => '81n9al10a0ayn13'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://development.knotapi.com/zero-link/batch/create"
payload := strings.NewReader("{\n \"type\": \"card_switcher\",\n \"users\": [\n {\n \"phone_number\": \"+12025550123\",\n \"external_user_id\": \"123abc\",\n \"card_id\": \"81n9al10a0ayn13\"\n },\n {\n \"phone_number\": \"+12025550124\",\n \"external_user_id\": \"456def\",\n \"card_id\": \"92o0bm21b1bzo24\"\n },\n {\n \"phone_number\": \"1234567892\",\n \"external_user_id\": \"789ghi\",\n \"card_id\": \"03p1cn32c2c0p35\"\n },\n {\n \"phone_number\": \"+12025550125\",\n \"external_user_id\": \"123abc\",\n \"card_id\": \"81n9al10a0ayn13\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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://development.knotapi.com/zero-link/batch/create")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"card_switcher\",\n \"users\": [\n {\n \"phone_number\": \"+12025550123\",\n \"external_user_id\": \"123abc\",\n \"card_id\": \"81n9al10a0ayn13\"\n },\n {\n \"phone_number\": \"+12025550124\",\n \"external_user_id\": \"456def\",\n \"card_id\": \"92o0bm21b1bzo24\"\n },\n {\n \"phone_number\": \"1234567892\",\n \"external_user_id\": \"789ghi\",\n \"card_id\": \"03p1cn32c2c0p35\"\n },\n {\n \"phone_number\": \"+12025550125\",\n \"external_user_id\": \"123abc\",\n \"card_id\": \"81n9al10a0ayn13\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://development.knotapi.com/zero-link/batch/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"card_switcher\",\n \"users\": [\n {\n \"phone_number\": \"+12025550123\",\n \"external_user_id\": \"123abc\",\n \"card_id\": \"81n9al10a0ayn13\"\n },\n {\n \"phone_number\": \"+12025550124\",\n \"external_user_id\": \"456def\",\n \"card_id\": \"92o0bm21b1bzo24\"\n },\n {\n \"phone_number\": \"1234567892\",\n \"external_user_id\": \"789ghi\",\n \"card_id\": \"03p1cn32c2c0p35\"\n },\n {\n \"phone_number\": \"+12025550125\",\n \"external_user_id\": \"123abc\",\n \"card_id\": \"81n9al10a0ayn13\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"links": [
{
"external_user_id": "123abc",
"card_id": "81n9al10a0ayn13",
"link": "https://clip.knotapi.com/switch?token=example_knot_zero_token_2xxxxxxxxxxxxxxxxxx",
"token": "example_knot_zero_token_2xxxxxxxxxxxxxxxxxx",
"error": null
},
{
"external_user_id": "456def",
"card_id": "92o0bm21b1bzo24",
"link": "https://clip.knotapi.com/switch?token=example_knot_zero_token_3xxxxxxxxxxxxxxxxxx",
"token": "example_knot_zero_token_3xxxxxxxxxxxxxxxxxx",
"error": null
},
{
"external_user_id": "789ghi",
"card_id": "03p1cn32c2c0p35",
"link": null,
"token": null,
"error": {
"error_type": "INVALID_REQUEST",
"error_code": "INVALID_FIELD",
"error_message": "The phone number format is invalid."
}
},
{
"external_user_id": "123abc",
"card_id": "81n9al10a0ayn13",
"link": null,
"token": null,
"error": {
"error_type": "INVALID_REQUEST",
"error_code": "INVALID_FIELD",
"error_message": "This user and card appear more than once in this request."
}
}
]
}Create Knot Zero Links (Batch)
Create Knot Zero links for up to 10,000 users in one request.
curl --request POST \
--url https://development.knotapi.com/zero-link/batch/create \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "card_switcher",
"users": [
{
"phone_number": "+12025550123",
"external_user_id": "123abc",
"card_id": "81n9al10a0ayn13"
},
{
"phone_number": "+12025550124",
"external_user_id": "456def",
"card_id": "92o0bm21b1bzo24"
},
{
"phone_number": "1234567892",
"external_user_id": "789ghi",
"card_id": "03p1cn32c2c0p35"
},
{
"phone_number": "+12025550125",
"external_user_id": "123abc",
"card_id": "81n9al10a0ayn13"
}
]
}
'import requests
url = "https://development.knotapi.com/zero-link/batch/create"
payload = {
"type": "card_switcher",
"users": [
{
"phone_number": "+12025550123",
"external_user_id": "123abc",
"card_id": "81n9al10a0ayn13"
},
{
"phone_number": "+12025550124",
"external_user_id": "456def",
"card_id": "92o0bm21b1bzo24"
},
{
"phone_number": "1234567892",
"external_user_id": "789ghi",
"card_id": "03p1cn32c2c0p35"
},
{
"phone_number": "+12025550125",
"external_user_id": "123abc",
"card_id": "81n9al10a0ayn13"
}
]
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
type: 'card_switcher',
users: [
{
phone_number: '+12025550123',
external_user_id: '123abc',
card_id: '81n9al10a0ayn13'
},
{
phone_number: '+12025550124',
external_user_id: '456def',
card_id: '92o0bm21b1bzo24'
},
{
phone_number: '1234567892',
external_user_id: '789ghi',
card_id: '03p1cn32c2c0p35'
},
{
phone_number: '+12025550125',
external_user_id: '123abc',
card_id: '81n9al10a0ayn13'
}
]
})
};
fetch('https://development.knotapi.com/zero-link/batch/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://development.knotapi.com/zero-link/batch/create",
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([
'type' => 'card_switcher',
'users' => [
[
'phone_number' => '+12025550123',
'external_user_id' => '123abc',
'card_id' => '81n9al10a0ayn13'
],
[
'phone_number' => '+12025550124',
'external_user_id' => '456def',
'card_id' => '92o0bm21b1bzo24'
],
[
'phone_number' => '1234567892',
'external_user_id' => '789ghi',
'card_id' => '03p1cn32c2c0p35'
],
[
'phone_number' => '+12025550125',
'external_user_id' => '123abc',
'card_id' => '81n9al10a0ayn13'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://development.knotapi.com/zero-link/batch/create"
payload := strings.NewReader("{\n \"type\": \"card_switcher\",\n \"users\": [\n {\n \"phone_number\": \"+12025550123\",\n \"external_user_id\": \"123abc\",\n \"card_id\": \"81n9al10a0ayn13\"\n },\n {\n \"phone_number\": \"+12025550124\",\n \"external_user_id\": \"456def\",\n \"card_id\": \"92o0bm21b1bzo24\"\n },\n {\n \"phone_number\": \"1234567892\",\n \"external_user_id\": \"789ghi\",\n \"card_id\": \"03p1cn32c2c0p35\"\n },\n {\n \"phone_number\": \"+12025550125\",\n \"external_user_id\": \"123abc\",\n \"card_id\": \"81n9al10a0ayn13\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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://development.knotapi.com/zero-link/batch/create")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"card_switcher\",\n \"users\": [\n {\n \"phone_number\": \"+12025550123\",\n \"external_user_id\": \"123abc\",\n \"card_id\": \"81n9al10a0ayn13\"\n },\n {\n \"phone_number\": \"+12025550124\",\n \"external_user_id\": \"456def\",\n \"card_id\": \"92o0bm21b1bzo24\"\n },\n {\n \"phone_number\": \"1234567892\",\n \"external_user_id\": \"789ghi\",\n \"card_id\": \"03p1cn32c2c0p35\"\n },\n {\n \"phone_number\": \"+12025550125\",\n \"external_user_id\": \"123abc\",\n \"card_id\": \"81n9al10a0ayn13\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://development.knotapi.com/zero-link/batch/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"card_switcher\",\n \"users\": [\n {\n \"phone_number\": \"+12025550123\",\n \"external_user_id\": \"123abc\",\n \"card_id\": \"81n9al10a0ayn13\"\n },\n {\n \"phone_number\": \"+12025550124\",\n \"external_user_id\": \"456def\",\n \"card_id\": \"92o0bm21b1bzo24\"\n },\n {\n \"phone_number\": \"1234567892\",\n \"external_user_id\": \"789ghi\",\n \"card_id\": \"03p1cn32c2c0p35\"\n },\n {\n \"phone_number\": \"+12025550125\",\n \"external_user_id\": \"123abc\",\n \"card_id\": \"81n9al10a0ayn13\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"links": [
{
"external_user_id": "123abc",
"card_id": "81n9al10a0ayn13",
"link": "https://clip.knotapi.com/switch?token=example_knot_zero_token_2xxxxxxxxxxxxxxxxxx",
"token": "example_knot_zero_token_2xxxxxxxxxxxxxxxxxx",
"error": null
},
{
"external_user_id": "456def",
"card_id": "92o0bm21b1bzo24",
"link": "https://clip.knotapi.com/switch?token=example_knot_zero_token_3xxxxxxxxxxxxxxxxxx",
"token": "example_knot_zero_token_3xxxxxxxxxxxxxxxxxx",
"error": null
},
{
"external_user_id": "789ghi",
"card_id": "03p1cn32c2c0p35",
"link": null,
"token": null,
"error": {
"error_type": "INVALID_REQUEST",
"error_code": "INVALID_FIELD",
"error_message": "The phone number format is invalid."
}
},
{
"external_user_id": "123abc",
"card_id": "81n9al10a0ayn13",
"link": null,
"token": null,
"error": {
"error_type": "INVALID_REQUEST",
"error_code": "INVALID_FIELD",
"error_message": "This user and card appear more than once in this request."
}
}
]
}error instead of a link without failing the rest of the request. Links are created together: if the request fails, no links are created and no earlier links are revoked.Authorizations
Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password. Use your client_id as the username and your secret as the password value.
Body
The users to create links for.
Product to associate the link with.
card_switcher "card_switcher"
The users to create links for. Maximum 10,000 users per request. A user can appear once per card. Later rows with the same external_user_id and card_id get an error.
1 - 10000 elementsShow child attributes
Show child attributes
Response
Successful request. Results are returned in the same order as users in the request. A user that fails validation returns an error instead of a link and doesn't fail the rest of the request.
One result per user, in request order.
Show child attributes
Show child attributes
Was this page helpful?