Batch Member Actions
Create Batch Job
POST
/
v1
/
members
/
jobs
cURL
curl --request POST \
--url https://api.onsi.com/v1/members/jobs \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"actions": [
{
"email": "jane-smith@onsi.com",
"firstName": "John",
"lastName": "Smith",
"tier": "Gold",
"type": "Add",
"phone": "+447123456789",
"workerId": "ID_123",
"accountDetails": {
"accountHolder": "John Smith",
"sortCode": "123456",
"accountNumber": "12345678"
},
"enablePayroll": true,
"dob": "1990-01-01"
}
]
}
'import requests
url = "https://api.onsi.com/v1/members/jobs"
payload = { "actions": [
{
"email": "jane-smith@onsi.com",
"firstName": "John",
"lastName": "Smith",
"tier": "Gold",
"type": "Add",
"phone": "+447123456789",
"workerId": "ID_123",
"accountDetails": {
"accountHolder": "John Smith",
"sortCode": "123456",
"accountNumber": "12345678"
},
"enablePayroll": True,
"dob": "1990-01-01"
}
] }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
actions: [
{
email: 'jane-smith@onsi.com',
firstName: 'John',
lastName: 'Smith',
tier: 'Gold',
type: 'Add',
phone: '+447123456789',
workerId: 'ID_123',
accountDetails: {accountHolder: 'John Smith', sortCode: '123456', accountNumber: '12345678'},
enablePayroll: true,
dob: '1990-01-01'
}
]
})
};
fetch('https://api.onsi.com/v1/members/jobs', 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.onsi.com/v1/members/jobs",
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([
'actions' => [
[
'email' => 'jane-smith@onsi.com',
'firstName' => 'John',
'lastName' => 'Smith',
'tier' => 'Gold',
'type' => 'Add',
'phone' => '+447123456789',
'workerId' => 'ID_123',
'accountDetails' => [
'accountHolder' => 'John Smith',
'sortCode' => '123456',
'accountNumber' => '12345678'
],
'enablePayroll' => true,
'dob' => '1990-01-01'
]
]
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.onsi.com/v1/members/jobs"
payload := strings.NewReader("{\n \"actions\": [\n {\n \"email\": \"jane-smith@onsi.com\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"tier\": \"Gold\",\n \"type\": \"Add\",\n \"phone\": \"+447123456789\",\n \"workerId\": \"ID_123\",\n \"accountDetails\": {\n \"accountHolder\": \"John Smith\",\n \"sortCode\": \"123456\",\n \"accountNumber\": \"12345678\"\n },\n \"enablePayroll\": true,\n \"dob\": \"1990-01-01\"\n }\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.onsi.com/v1/members/jobs")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"actions\": [\n {\n \"email\": \"jane-smith@onsi.com\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"tier\": \"Gold\",\n \"type\": \"Add\",\n \"phone\": \"+447123456789\",\n \"workerId\": \"ID_123\",\n \"accountDetails\": {\n \"accountHolder\": \"John Smith\",\n \"sortCode\": \"123456\",\n \"accountNumber\": \"12345678\"\n },\n \"enablePayroll\": true,\n \"dob\": \"1990-01-01\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.onsi.com/v1/members/jobs")
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 \"actions\": [\n {\n \"email\": \"jane-smith@onsi.com\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"tier\": \"Gold\",\n \"type\": \"Add\",\n \"phone\": \"+447123456789\",\n \"workerId\": \"ID_123\",\n \"accountDetails\": {\n \"accountHolder\": \"John Smith\",\n \"sortCode\": \"123456\",\n \"accountNumber\": \"12345678\"\n },\n \"enablePayroll\": true,\n \"dob\": \"1990-01-01\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"jobId": "maj_cltd2zp7100096tmbamb9c46o"
}Creates a new job, which runs asynchronously and returns a job ID. The job ID can be used to check the status of the job.
The job contains an array of operations, of the same format as the single changes APIs:
- Add - Invites a new member to your Onsi programme.
- Replace - Replaces the member’s data with new information. An inactive member will be re-added to Onsi.
- Update - Updates the member’s data with new information. Does not re-add inactive members.
- Remove - Removes the member from your Onsi programme.
Unsetting Bank Details
For Replace and Update operations, you can remove a member’s bank details by settingaccountDetails to null.
Relevant Error Codes
If there are issues with any of the operations, the API will return a400 status code with the following error codes:
If there are issues, Onsi will not process any of the operations in your request, and will not create a job. You will
need to fix the issues and send a subsequent request.
Authorizations
Headers
Unique key to ensure idempotency of the request
Body
application/json
Body
Minimum array length:
1Add a new member
- Add
- Replace
- Update
- Offboard
Show child attributes
Show child attributes
Response
202 - application/json
202
Example:
"maj_cltd2zp7100096tmbamb9c46o"
⌘I
cURL
curl --request POST \
--url https://api.onsi.com/v1/members/jobs \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"actions": [
{
"email": "jane-smith@onsi.com",
"firstName": "John",
"lastName": "Smith",
"tier": "Gold",
"type": "Add",
"phone": "+447123456789",
"workerId": "ID_123",
"accountDetails": {
"accountHolder": "John Smith",
"sortCode": "123456",
"accountNumber": "12345678"
},
"enablePayroll": true,
"dob": "1990-01-01"
}
]
}
'import requests
url = "https://api.onsi.com/v1/members/jobs"
payload = { "actions": [
{
"email": "jane-smith@onsi.com",
"firstName": "John",
"lastName": "Smith",
"tier": "Gold",
"type": "Add",
"phone": "+447123456789",
"workerId": "ID_123",
"accountDetails": {
"accountHolder": "John Smith",
"sortCode": "123456",
"accountNumber": "12345678"
},
"enablePayroll": True,
"dob": "1990-01-01"
}
] }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
actions: [
{
email: 'jane-smith@onsi.com',
firstName: 'John',
lastName: 'Smith',
tier: 'Gold',
type: 'Add',
phone: '+447123456789',
workerId: 'ID_123',
accountDetails: {accountHolder: 'John Smith', sortCode: '123456', accountNumber: '12345678'},
enablePayroll: true,
dob: '1990-01-01'
}
]
})
};
fetch('https://api.onsi.com/v1/members/jobs', 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.onsi.com/v1/members/jobs",
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([
'actions' => [
[
'email' => 'jane-smith@onsi.com',
'firstName' => 'John',
'lastName' => 'Smith',
'tier' => 'Gold',
'type' => 'Add',
'phone' => '+447123456789',
'workerId' => 'ID_123',
'accountDetails' => [
'accountHolder' => 'John Smith',
'sortCode' => '123456',
'accountNumber' => '12345678'
],
'enablePayroll' => true,
'dob' => '1990-01-01'
]
]
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.onsi.com/v1/members/jobs"
payload := strings.NewReader("{\n \"actions\": [\n {\n \"email\": \"jane-smith@onsi.com\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"tier\": \"Gold\",\n \"type\": \"Add\",\n \"phone\": \"+447123456789\",\n \"workerId\": \"ID_123\",\n \"accountDetails\": {\n \"accountHolder\": \"John Smith\",\n \"sortCode\": \"123456\",\n \"accountNumber\": \"12345678\"\n },\n \"enablePayroll\": true,\n \"dob\": \"1990-01-01\"\n }\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.onsi.com/v1/members/jobs")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"actions\": [\n {\n \"email\": \"jane-smith@onsi.com\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"tier\": \"Gold\",\n \"type\": \"Add\",\n \"phone\": \"+447123456789\",\n \"workerId\": \"ID_123\",\n \"accountDetails\": {\n \"accountHolder\": \"John Smith\",\n \"sortCode\": \"123456\",\n \"accountNumber\": \"12345678\"\n },\n \"enablePayroll\": true,\n \"dob\": \"1990-01-01\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.onsi.com/v1/members/jobs")
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 \"actions\": [\n {\n \"email\": \"jane-smith@onsi.com\",\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"tier\": \"Gold\",\n \"type\": \"Add\",\n \"phone\": \"+447123456789\",\n \"workerId\": \"ID_123\",\n \"accountDetails\": {\n \"accountHolder\": \"John Smith\",\n \"sortCode\": \"123456\",\n \"accountNumber\": \"12345678\"\n },\n \"enablePayroll\": true,\n \"dob\": \"1990-01-01\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"jobId": "maj_cltd2zp7100096tmbamb9c46o"
}