Invitations
Create invitations
Creates a batch of invitations. Invitations are supported only for SURVEY Studies, not IN_PRODUCT_SURVEY Studies.
POST
/
v2
/
studies
/
{studyId}
/
invitations
Create invitations
curl --request POST \
--url https://api.sprig.com/v2/studies/{studyId}/invitations \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"count": 5000,
"idempotencyKey": "<string>"
}
'import requests
url = "https://api.sprig.com/v2/studies/{studyId}/invitations"
payload = {
"count": 5000,
"idempotencyKey": "<string>"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({count: 5000, idempotencyKey: '<string>'})
};
fetch('https://api.sprig.com/v2/studies/{studyId}/invitations', 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://api.sprig.com/v2/studies/{studyId}/invitations",
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([
'count' => 5000,
'idempotencyKey' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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://api.sprig.com/v2/studies/{studyId}/invitations"
payload := strings.NewReader("{\n \"count\": 5000,\n \"idempotencyKey\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<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.sprig.com/v2/studies/{studyId}/invitations")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"count\": 5000,\n \"idempotencyKey\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sprig.com/v2/studies/{studyId}/invitations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"count\": 5000,\n \"idempotencyKey\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"invitations": [
{
"code": "<string>",
"url": "<string>"
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}Authorizations
Use API-Key YOUR_API_KEY. The key selects the Production or Development environment.
Path Parameters
Body
application/json
A request for one batch of invitations.
How many invitations to generate.
Required range:
1 <= x <= 10000A key you choose to name this batch. Sending the same key again returns the batch it first created and generates nothing new, even if count differs, so a retried request never doubles up on invitations.
Minimum string length:
1Response
Invitation batch created or returned for the idempotency key.
One generated invitation batch.
Generated invitations in creation order.
Show child attributes
Show child attributes
Was this page helpful?
⌘I
Create invitations
curl --request POST \
--url https://api.sprig.com/v2/studies/{studyId}/invitations \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"count": 5000,
"idempotencyKey": "<string>"
}
'import requests
url = "https://api.sprig.com/v2/studies/{studyId}/invitations"
payload = {
"count": 5000,
"idempotencyKey": "<string>"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({count: 5000, idempotencyKey: '<string>'})
};
fetch('https://api.sprig.com/v2/studies/{studyId}/invitations', 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://api.sprig.com/v2/studies/{studyId}/invitations",
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([
'count' => 5000,
'idempotencyKey' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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://api.sprig.com/v2/studies/{studyId}/invitations"
payload := strings.NewReader("{\n \"count\": 5000,\n \"idempotencyKey\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<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.sprig.com/v2/studies/{studyId}/invitations")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"count\": 5000,\n \"idempotencyKey\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sprig.com/v2/studies/{studyId}/invitations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"count\": 5000,\n \"idempotencyKey\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"invitations": [
{
"code": "<string>",
"url": "<string>"
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}{
"code": "<string>",
"message": "<string>",
"errors": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"resource": {
"type": "<string>",
"id": "<string>"
}
}
]
}