Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt
hiddentrue

POST /v2/subscriptions

V2 Summary

To receive callbacks for particular container events, you need to create a subscription by POSTing to the subscriptions endpoint.

...

For the eventTypeCodes we allow for more than 10 event types to be specified in the subscription request. Users can also use the "ALL" to subscribe to all event types.

V1 vs V2 differences

Version 1 allows a single container visit event type code per request, Version 2 supports multiple container visit event type codes in a single request. Version 2 also supports the use of “ALL” to subscribe to all events for one or more containers.

Endpoint

Code Block
POST https://api.portconnect.io/v2/subscriptions

Request Body with Container Numbers

Code Block
breakoutModewide
languagejson
{
  "containers": [
    { "containerNumber": "MEDU3085895", "userDefinedReference" : "User ref 1"},
    { "containerNumber": "APHU6303593", "userDefinedReference" : "User ref 2"},
    { "containerNumber": "MEDU5129708", "userDefinedReference" : "User ref 3"}
  ],
  "webhookURI": "https://api.yourcompany.co.nz/webhooks/portconnect", // Optional if emailAddressList is present
  "webhookToken": "yoursecret", // Optional if emailAddressList is present
  "emailAddressList": ["me@test.com"], // Optional if webhookURI and webhookToken are present
  "portCode": "NZTRG",
  "category": "IMPORT",
  "eventTypeCodes": ["ALL", "Discharge"],
  "facilityCode": null
}

 

Response Body with containers:

Code Block
languagejson
{
    "subscriptionId": 32,
    "containers": [
        {
            "expirationDatetime": "2023-06-20T14:50:30.3+12:00",
            "containerNumber": "TCNU8050683",
            "userDefinedReference": "Azure Test 2"
        }
    ]
}

 

Request example using Booking Numbers

When creating a subscription against a Booking Number, callbacks will be sent for any Export containers with the specified booking number.

Request Body with Booking Numbers

Code Block
breakoutModewide
languagejson
{
  "bookings": [
    { "bookingNumber": "LOPReferenc1", "userDefinedReference" : "User ref 1"}
  ],
  "webhookURI": "https://api.yourcompany.co.nz/webhooks/portconnect", // Optional if emailAddressList is present
  "webhookToken": "yoursecret", // Optional if emailAddressList is present
  "emailAddressList": ["me@test.com"], // Optional if webhookURI and webhookToken are present
  "portCode": "NZTRG",
  "category": "EXPORT",
  "eventTypeCodes": ["ALL", "Load"],
  "facilityCode": null
}

 

Response Body with bookings:

Code Block
languagejson
{
    "subscriptionId": 32,
    "bookings": [
        {
            "expirationDatetime": "2023-06-20T14:50:30.3+12:00",
            "bookingNumber": "LOPReferenc1",
            "userDefinedReference": "User ref 12"
        }
    ]
}

...