import shippo
from shippo.models import components
s = shippo.Shippo(
api_key_header='ShippoToken <API_TOKEN>',
shippo_api_version='2018-02-08',
)
res = s.webhooks.create_webhook(request=components.WebhookUpdateRequest(
event=components.WebhookEventTypeEnum.BATCH_CREATED,
url='https://example.com/shippo-webhook',
active=True,
is_test=False,
))
if res is not None:
# handle response
passimport { Shippo } from "shippo";
const shippo = new Shippo({
apiKeyHeader: "ShippoToken <API_TOKEN>",
shippoApiVersion: "2018-02-08",
});
async function run() {
const result = await shippo.webhooks.createWebhook({
event: "batch_created",
url: "https://example.com/shippo-webhook",
active: true,
isTest: false,
});
// Handle the result
console.log(result);
}
run();using Shippo;
using Shippo.Models.Components;
var sdk = new ShippoSDK(
apiKeyHeader: "ShippoToken <API_TOKEN>",
shippoApiVersion: "2018-02-08"
);
WebhookUpdateRequest req = new WebhookUpdateRequest() {
Event = WebhookEventTypeEnum.BatchCreated,
Url = "https://example.com/shippo-webhook",
Active = true,
IsTest = false,
};
var res = await sdk.Webhooks.CreateWebhookAsync(req);
// handle responsedeclare(strict_types=1);
require 'vendor/autoload.php';
use Shippo\API;
use Shippo\API\Models\Components;
$sdk = API\Shippo::builder()
->setSecurity(
'ShippoToken <API_TOKEN>'
)
->setShippoApiVersion('2018-02-08')
->build();
$request = new Components\WebhookUpdateRequest(
event: Components\WebhookEventTypeEnum::BatchCreated,
url: 'https://example.com/shippo-webhook',
active: true,
isTest: false,
);
$response = $sdk->webhooks->createWebhook(
request: $request
);
if ($response->webhook !== null) {
// handle response
}package hello.world;
import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.components.WebhookEventTypeEnum;
import com.goshippo.shippo_sdk.models.components.WebhookUpdateRequest;
import com.goshippo.shippo_sdk.models.operations.CreateWebhookResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Shippo sdk = Shippo.builder()
.apiKeyHeader("ShippoToken <API_TOKEN>")
.shippoApiVersion("2018-02-08")
.build();
WebhookUpdateRequest req = WebhookUpdateRequest.builder()
.event(WebhookEventTypeEnum.BATCH_CREATED)
.url("https://example.com/shippo-webhook")
.active(true)
.isTest(false)
.build();
CreateWebhookResponse res = sdk.webhooks().createWebhook()
.request(req)
.call();
if (res.webhook().isPresent()) {
// handle response
}
}
}curl --request POST \
--url https://api.goshippo.com/webhooks \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"event": "track_updated",
"url": "https://example.com/shippo-webhook",
"active": true,
"is_test": false
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
event: 'track_updated',
url: 'https://example.com/shippo-webhook',
active: true,
is_test: false
})
};
fetch('https://api.goshippo.com/webhooks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.goshippo.com/webhooks"
payload := strings.NewReader("{\n \"event\": \"track_updated\",\n \"url\": \"https://example.com/shippo-webhook\",\n \"active\": true,\n \"is_test\": false\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))
}require 'uri'
require 'net/http'
url = URI("https://api.goshippo.com/webhooks")
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 \"event\": \"track_updated\",\n \"url\": \"https://example.com/shippo-webhook\",\n \"active\": true,\n \"is_test\": false\n}"
response = http.request(request)
puts response.read_body{
"event": "track_updated",
"url": "https://example.com/shippo-webhook",
"active": true,
"is_test": false,
"object_created": "2023-11-07T05:31:56Z",
"object_id": "<string>",
"object_updated": "2023-11-07T05:31:56Z",
"object_owner": "<string>"
}Create a new webhook
Creates a new webhook to send notifications to a URL when a specific event occurs.
import shippo
from shippo.models import components
s = shippo.Shippo(
api_key_header='ShippoToken <API_TOKEN>',
shippo_api_version='2018-02-08',
)
res = s.webhooks.create_webhook(request=components.WebhookUpdateRequest(
event=components.WebhookEventTypeEnum.BATCH_CREATED,
url='https://example.com/shippo-webhook',
active=True,
is_test=False,
))
if res is not None:
# handle response
passimport { Shippo } from "shippo";
const shippo = new Shippo({
apiKeyHeader: "ShippoToken <API_TOKEN>",
shippoApiVersion: "2018-02-08",
});
async function run() {
const result = await shippo.webhooks.createWebhook({
event: "batch_created",
url: "https://example.com/shippo-webhook",
active: true,
isTest: false,
});
// Handle the result
console.log(result);
}
run();using Shippo;
using Shippo.Models.Components;
var sdk = new ShippoSDK(
apiKeyHeader: "ShippoToken <API_TOKEN>",
shippoApiVersion: "2018-02-08"
);
WebhookUpdateRequest req = new WebhookUpdateRequest() {
Event = WebhookEventTypeEnum.BatchCreated,
Url = "https://example.com/shippo-webhook",
Active = true,
IsTest = false,
};
var res = await sdk.Webhooks.CreateWebhookAsync(req);
// handle responsedeclare(strict_types=1);
require 'vendor/autoload.php';
use Shippo\API;
use Shippo\API\Models\Components;
$sdk = API\Shippo::builder()
->setSecurity(
'ShippoToken <API_TOKEN>'
)
->setShippoApiVersion('2018-02-08')
->build();
$request = new Components\WebhookUpdateRequest(
event: Components\WebhookEventTypeEnum::BatchCreated,
url: 'https://example.com/shippo-webhook',
active: true,
isTest: false,
);
$response = $sdk->webhooks->createWebhook(
request: $request
);
if ($response->webhook !== null) {
// handle response
}package hello.world;
import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.components.WebhookEventTypeEnum;
import com.goshippo.shippo_sdk.models.components.WebhookUpdateRequest;
import com.goshippo.shippo_sdk.models.operations.CreateWebhookResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Shippo sdk = Shippo.builder()
.apiKeyHeader("ShippoToken <API_TOKEN>")
.shippoApiVersion("2018-02-08")
.build();
WebhookUpdateRequest req = WebhookUpdateRequest.builder()
.event(WebhookEventTypeEnum.BATCH_CREATED)
.url("https://example.com/shippo-webhook")
.active(true)
.isTest(false)
.build();
CreateWebhookResponse res = sdk.webhooks().createWebhook()
.request(req)
.call();
if (res.webhook().isPresent()) {
// handle response
}
}
}curl --request POST \
--url https://api.goshippo.com/webhooks \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"event": "track_updated",
"url": "https://example.com/shippo-webhook",
"active": true,
"is_test": false
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
event: 'track_updated',
url: 'https://example.com/shippo-webhook',
active: true,
is_test: false
})
};
fetch('https://api.goshippo.com/webhooks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.goshippo.com/webhooks"
payload := strings.NewReader("{\n \"event\": \"track_updated\",\n \"url\": \"https://example.com/shippo-webhook\",\n \"active\": true,\n \"is_test\": false\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))
}require 'uri'
require 'net/http'
url = URI("https://api.goshippo.com/webhooks")
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 \"event\": \"track_updated\",\n \"url\": \"https://example.com/shippo-webhook\",\n \"active\": true,\n \"is_test\": false\n}"
response = http.request(request)
puts response.read_body{
"event": "track_updated",
"url": "https://example.com/shippo-webhook",
"active": true,
"is_test": false,
"object_created": "2023-11-07T05:31:56Z",
"object_id": "<string>",
"object_updated": "2023-11-07T05:31:56Z",
"object_owner": "<string>"
}Authorizations
API key authentication using the ShippoToken scheme. Format: Authorization: ShippoToken <API_TOKEN> Example: Authorization: ShippoToken shippo_live_abc123
Body
Type of event that triggered the webhook.
transaction_created, transaction_updated, track_updated, batch_created, batch_purchased, all "track_updated"
URL webhook events are sent to.
"https://example.com/shippo-webhook"
Determines whether the webhook is active or not.
true
Determines whether the webhook is a test webhook or not.
false
Response
Webhook created successfully
Type of event that triggers the webhook.
"track_updated"
URL webhook events are sent to.
"https://example.com/shippo-webhook"
Determines whether the webhook is active or not.
true
Determines whether the webhook is a test webhook or not.
false
Timestamp of the creation of the webhook.
Unique identifier of the webhook. This can be used to retrieve or delete the webhook.
Timestamp of the last update of the webhook.
Username of the user who created the webhook.
Was this page helpful?