Update a contract
curl --request PATCH \
--url https://panel.sendcloud.sc/api/v3/contracts/{id} \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"is_active": false,
"is_default_per_carrier": false,
"contract_data": {
"country": "NL",
"client_id": "sendcloud-1"
},
"name": "main"
}
'import requests
url = "https://panel.sendcloud.sc/api/v3/contracts/{id}"
payload = {
"is_active": False,
"is_default_per_carrier": False,
"contract_data": {
"country": "NL",
"client_id": "sendcloud-1"
},
"name": "main"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
is_active: false,
is_default_per_carrier: false,
contract_data: {country: 'NL', client_id: 'sendcloud-1'},
name: 'main'
})
};
fetch('https://panel.sendcloud.sc/api/v3/contracts/{id}', 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://panel.sendcloud.sc/api/v3/contracts/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'is_active' => false,
'is_default_per_carrier' => false,
'contract_data' => [
'country' => 'NL',
'client_id' => 'sendcloud-1'
],
'name' => 'main'
]),
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://panel.sendcloud.sc/api/v3/contracts/{id}"
payload := strings.NewReader("{\n \"is_active\": false,\n \"is_default_per_carrier\": false,\n \"contract_data\": {\n \"country\": \"NL\",\n \"client_id\": \"sendcloud-1\"\n },\n \"name\": \"main\"\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://panel.sendcloud.sc/api/v3/contracts/{id}")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"is_active\": false,\n \"is_default_per_carrier\": false,\n \"contract_data\": {\n \"country\": \"NL\",\n \"client_id\": \"sendcloud-1\"\n },\n \"name\": \"main\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://panel.sendcloud.sc/api/v3/contracts/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"is_active\": false,\n \"is_default_per_carrier\": false,\n \"contract_data\": {\n \"country\": \"NL\",\n \"client_id\": \"sendcloud-1\"\n },\n \"name\": \"main\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 60,
"carrier": {
"code": "lettresuivie",
"name": "Lettre Suivie"
},
"client_id": "sendcloud-1",
"is_default_per_carrier": true,
"state": "active",
"type": "direct"
}
}{
"errors": [
{
"detail": "This field is required.",
"status": "400",
"source": {
"pointer": "/data/client_id"
},
"code": "required"
}
]
}{
"errors": [
{
"status": "<string>",
"code": "unknown_field",
"detail": "<string>",
"id": "<string>",
"links": {
"about": "<string>"
},
"title": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>",
"header": "<string>"
},
"meta": {}
}
]
}Contracts
Update a contract
Update or replace a contract by including the id of the contract as a path parameter.
PATCH
/
contracts
/
{id}
Update a contract
curl --request PATCH \
--url https://panel.sendcloud.sc/api/v3/contracts/{id} \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"is_active": false,
"is_default_per_carrier": false,
"contract_data": {
"country": "NL",
"client_id": "sendcloud-1"
},
"name": "main"
}
'import requests
url = "https://panel.sendcloud.sc/api/v3/contracts/{id}"
payload = {
"is_active": False,
"is_default_per_carrier": False,
"contract_data": {
"country": "NL",
"client_id": "sendcloud-1"
},
"name": "main"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
is_active: false,
is_default_per_carrier: false,
contract_data: {country: 'NL', client_id: 'sendcloud-1'},
name: 'main'
})
};
fetch('https://panel.sendcloud.sc/api/v3/contracts/{id}', 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://panel.sendcloud.sc/api/v3/contracts/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'is_active' => false,
'is_default_per_carrier' => false,
'contract_data' => [
'country' => 'NL',
'client_id' => 'sendcloud-1'
],
'name' => 'main'
]),
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://panel.sendcloud.sc/api/v3/contracts/{id}"
payload := strings.NewReader("{\n \"is_active\": false,\n \"is_default_per_carrier\": false,\n \"contract_data\": {\n \"country\": \"NL\",\n \"client_id\": \"sendcloud-1\"\n },\n \"name\": \"main\"\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://panel.sendcloud.sc/api/v3/contracts/{id}")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"is_active\": false,\n \"is_default_per_carrier\": false,\n \"contract_data\": {\n \"country\": \"NL\",\n \"client_id\": \"sendcloud-1\"\n },\n \"name\": \"main\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://panel.sendcloud.sc/api/v3/contracts/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"is_active\": false,\n \"is_default_per_carrier\": false,\n \"contract_data\": {\n \"country\": \"NL\",\n \"client_id\": \"sendcloud-1\"\n },\n \"name\": \"main\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 60,
"carrier": {
"code": "lettresuivie",
"name": "Lettre Suivie"
},
"client_id": "sendcloud-1",
"is_default_per_carrier": true,
"state": "active",
"type": "direct"
}
}{
"errors": [
{
"detail": "This field is required.",
"status": "400",
"source": {
"pointer": "/data/client_id"
},
"code": "required"
}
]
}{
"errors": [
{
"status": "<string>",
"code": "unknown_field",
"detail": "<string>",
"id": "<string>",
"links": {
"about": "<string>"
},
"title": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>",
"header": "<string>"
},
"meta": {}
}
]
}OAuth2 scopes required:
write:carrier. See Scopes for OAuth apps.name, is_active, is_default, is_default_per_carrier).
However, used contracts are immutable; if you change the contract_data of a contract that has already been used for shipments,
it will cause a new contract ID to be created. In this case, the old one will no longer be active for use.
After updating a contract with contract_data, we need to validate it again and its state will be "validating".
During the validation the contract is not active and cannot be used for creating shipments. The validation
process is asynchronous and will happen in the background.
Once validation is complete, the contract’s state will change to one of the following:
"active"or"inactive": The contract has been successfully processed."validation_failed": An error occurred during validation. Additional information about the failure will be provided.
Authorizations
HTTPBasicAuthOAuth2ClientCreds
Body
application/json
Update request object model
Marks the contract as default for a carrier. You can have only one default direct contract per carrier.
Note: You cannot mark a contract as not default, to switch the default contract of a carrier use is_default_per_carrier: true on the contract you'd like to set as default; other contracts for this carrier will automatically be marked as not default.
Example:
false