(webhooks())
Webhooks are a way for Shippo to notify your application when a specific event occurs. For example, when a label is purchased or when a shipment tracking status has changed. You can use webhooks to trigger actions in your application, such as sending an email or updating a database.
The payload is the body of the POST request Shippo sends to the URL specified at the time of webhook registration.
Creates a new webhook to send notifications to a URL when a specific event occurs.
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("<YOUR_API_KEY_HERE>")
.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
}
}
}
Parameter |
Type |
Required |
Description |
request |
WebhookUpdateRequest |
✔️ |
The request object to use for the request. |
CreateWebhookResponse
Error Type |
Status Code |
Content Type |
models/errors/SDKError |
4XX, 5XX |
*/* |
Returns a list of all webhooks you have created.
package hello.world;
import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.operations.ListWebhooksResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Shippo sdk = Shippo.builder()
.apiKeyHeader("<YOUR_API_KEY_HERE>")
.shippoApiVersion("2018-02-08")
.build();
ListWebhooksResponse res = sdk.webhooks().listWebhooks()
.call();
if (res.webhookPaginatedList().isPresent()) {
// handle response
}
}
}
ListWebhooksResponse
Error Type |
Status Code |
Content Type |
models/errors/SDKError |
4XX, 5XX |
*/* |
Returns the details of a specific webhook using the webhook object ID.
package hello.world;
import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.operations.GetWebhookResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Shippo sdk = Shippo.builder()
.apiKeyHeader("<YOUR_API_KEY_HERE>")
.shippoApiVersion("2018-02-08")
.build();
GetWebhookResponse res = sdk.webhooks().getWebhook()
.webhookId("<id>")
.call();
if (res.webhook().isPresent()) {
// handle response
}
}
}
Parameter |
Type |
Required |
Description |
webhookId |
String |
✔️ |
Object ID of the webhook to retrieve |
GetWebhookResponse
Error Type |
Status Code |
Content Type |
models/errors/SDKError |
4XX, 5XX |
*/* |
Updates an existing webhook using the webhook object ID.
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.UpdateWebhookResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Shippo sdk = Shippo.builder()
.apiKeyHeader("<YOUR_API_KEY_HERE>")
.shippoApiVersion("2018-02-08")
.build();
UpdateWebhookResponse res = sdk.webhooks().updateWebhook()
.webhookId("<id>")
.webhookUpdateRequest(WebhookUpdateRequest.builder()
.event(WebhookEventTypeEnum.BATCH_CREATED)
.url("https://example.com/shippo-webhook")
.active(true)
.isTest(false)
.build())
.call();
if (res.webhook().isPresent()) {
// handle response
}
}
}
Parameter |
Type |
Required |
Description |
webhookId |
String |
✔️ |
Object ID of the webhook to retrieve |
webhookUpdateRequest |
WebhookUpdateRequest |
✔️ |
N/A |
UpdateWebhookResponse
Error Type |
Status Code |
Content Type |
models/errors/SDKError |
4XX, 5XX |
*/* |
Deletes a specific webhook using the webhook object ID.
package hello.world;
import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.operations.DeleteWebhookResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Shippo sdk = Shippo.builder()
.apiKeyHeader("<YOUR_API_KEY_HERE>")
.shippoApiVersion("2018-02-08")
.build();
DeleteWebhookResponse res = sdk.webhooks().deleteWebhook()
.webhookId("<id>")
.call();
// handle response
}
}
Parameter |
Type |
Required |
Description |
webhookId |
String |
✔️ |
Object ID of the webhook to delete |
DeleteWebhookResponse
Error Type |
Status Code |
Content Type |
models/errors/SDKError |
4XX, 5XX |
*/* |