Webhook Subscription


 

The methods are used to manage the subscription of webhooks to be sent to the client's URL.

Since the CDEK test account is common for all clients, only production CDEK URL should be used for testing the webhooks.
Specify your test URL to which the webhooks are to be sent, in your request for subscription. After completion of the testing, change it to your production URL.

1.Adding the Subscription

The method is used to add the webhook subscription.
At present, you can subscribe for order status events and print forms readiness.

Request for Adding the Subscription

In order to use this process, a POST request should be sent to URL: https://api.cdek.ru/v2/webhooks.

The request body should be sent in the JSON format (Content-Type: application/json).

The following fields are supported:

No.

Field name

Description

Field type

Mandatory (yes/no)

1

url

URL to which the client wants to receive webhooks

string()

yes

2

type1

Event Type:
ORDER_STATUS - event by statuses
PRINT_FORM - readiness of printed form
DOWNLOAD_PHOTO - receiving photo documents on orders
PREALERT_CLOSED - receiving information about prealert closing

string()

yes

1 If the client already has a subscription with the specified type, the previous url will be changed to a new one.

Response to the Request for Adding the Subscription

The response body is returned in the JSON format:

No.

Field name

Description

Field type

Mandatory (yes/no)

1entityData of the subscription over which request is sent
no

1.1

uuid

Subscription identifier

UUID

yes

2requestsData on the request/requests over the subscription request[]yes
2.1request_uuidSubscription  identifier in CDEK information systemUUIDno
2.2typeRequest type
May take on values: CREATE, UPDATE, DELETE, AUTH, GET
string()yes
2.3state

Current status of the request
May take on values: 

ACCEPTED - pre-validation passed and request accepted
WAITING - the request is awaiting processing (depends on the execution of another request)
SUCCESSFUL - the request was processed successfully
INVALID - the request was processed with an error

string()yes
2.4date_timeDate and time of setting current status of the request (format yyyy-MM-dd'T'HH:mm:ssZ)datetimeyes
2.5errorsRequest processing errorserror[]no
2.5.1codeError codestring()yes
2.5.2messageError descriptionstring()yes
2.6warningsRequest processing warningswarning[]no
2.6.1codeWarning codestring()yes
2.6.2messageWarning descriptionstring()yes


{
    "url":"https://webhook.site",
    "type":"ORDER_STATUS"
}


{
    "entity": {
        "uuid": "73c65d02-51a9-4423-8ee8-cc662ec3eb85"
    },
    "requests": [
        {
            "request_uuid": "72753031-0e1b-4f1d-abcc-b0bb0bd6ab2f",
            "type": "CREATE",
            "state": "SUCCESSFUL",
            "date_time": "2020-02-10T12:14:57+0000",
            "errors": [],
            "warnings": []
        }
    ]
}

2. Details of Subscription

The method is used to get details of client's webhook subscription(-s).

Request for Details of Subscription

In order to use this process, a GET request should be sent to URL:

Response to the Request for Details of Subscription

The response body is returned in the JSON format:

No.

Field name

Description

Field type

Mandatory (yes/no)

1entityData of the subscription over which request is sent
no

1.1

uuid

Subscription identifier

UUID

yes

1.2

url

URL to which webhooks are sent for the client

string()

yes

1.3

type

Event type

string()

yes

2requestsData on the request/requests over the subscriptionrequest[]yes
2.1request_uuidSubscription  identifier in CDEK information systemUUIDno
2.2typeRequest type
May take on values: CREATE, UPDATE, DELETE, AUTH, GET
string()yes
2.3state

Current status of the request
May take on values: 

ACCEPTED - pre-validation passed and request accepted
WAITING - the request is awaiting processing (depends on the execution of another request)
SUCCESSFUL - the request was processed successfully
INVALID - the request was processed with an error

string()yes
2.4date_timeDate and time of setting current status of the request (format yyyy-MM-dd'T'HH:mm:ssZ)datetimeyes
2.5errorsRequest processing errorserror[]no
2.5.1codeError codestring()yes
2.5.2messageError descriptionstring()yes
2.6warningsRequest processing warningswarning[]no
2.6.1codeWarning codestring()yes
2.6.2messageWarning descriptionstring()yes


https://api.cdek.ru/v2/webhooks/73c65d02-51a9-4423-8ee8-cc662ec3eb85


{
    "entity": {
        "uuid": "73c65d02-51a9-4423-8ee8-cc662ec3eb85",
        "type": "ORDER_STATUS",
        "url": "https://webhook.site"
    },
    "requests": [
        {
            "request_uuid": "72753031-5ae3-448f-ba78-ea29d08e89fa",
            "type": "CREATE",
            "state": "SUCCESSFUL",
            "date_time": "2020-02-10T12:17:06+0000",
            "errors": [],
            "warnings": []
        }
    ]
}

Response to retrieve information about all current subscriptions.
The response is returned in JSON format:

Response to retrieve information about all current subscriptions. 

The response is returnes in JSON format:

Field nameDescriptionField typeMandatory
1.1 uuid Subscription IDUUIDда
1.2url URL to which the client receives webhooksstring()да
1.3type Event Typestring()да
1.4requestsRequest informationrequest[]нет
    1.4.1typeRequest type.
Can take the following values: CREATE, UPDATE, DELETE, AUTH, GET
string()да
    1.4.2date_timeDate and time to set the current request state (format yyyy-MM-dd'T'HH:mm:ssZ)datetimeда
    1.4.3stateCurrent state of the requestCan take the following values: ACCEPTED - preliminary validation has been passed and the request is acceptedWAITING - the request is waiting for processing (depends on the execution of another request)SUCCESSFUL - the request has been processed successfullyINVALID - the request has been processed with an error. string() да
    1.4.4errorsErrors that occurred during the query executionerror[]нет
       1.4.4.1codeError codestring()да
       1.4.4.2messageError descriptionstring()да
    1.4.5warningsWarnings that occurred during query executionwarning[]нет
        1.4.5.1codeWarning codestring()да
        1.4.5.2messageWarning descriptionstring()да


https://api.cdek.ru/v2/webhooks/


[
    {
        "type": "ORDER_STATUS",
        "uuid": "d7da1dbd-ae19-4f86-ab85-3274fa96ea8e",
        "url": "https://webhook.site/"
    },
    {
        "type": "PRINT_FORM",
        "uuid": "6624c7c0-680a-4c4e-9ed7-3f48ca9df4f4",
        "url": "https://webhook.site/"
    },
    {
        "type": "DOWNLOAD_PHOTO",
        "uuid": "41b9c676-bb54-4107-ba32-30ad4f1e9c7b",
        "url": "https://webhook.site/"
    },
    {
        "type": "PREALERT_CLOSED",
        "uuid": "0d15c501-8ed5-4f44-a462-ea7ec37cea22",
        "url": "https://webhook.site/"
    }
]


3. Deleting the Subscription

The method is used to delete the webhook subscription.

Request for Deleting the Subscription

In order to use this process, a DELETE request should be sent to URL:

https://api.cdek.ru/v2/webhooks/{uuid}, where uuid is the subscription identifier

Response to the Request for Deleting the Subscription

The response body is returned in the JSON format:

No.

Field name

Description

Field type

Mandatory (yes/no)

1entityData of the subscription over which request is sent
no

1.1

uuid

Identifier of the deleted subscription

UUID

yes

2requestsData on the request/requests over the subscriptionrequest[]yes
2.1request_uuidSubscription  identifier in CDEK information systemUUIDno
2.2typeRequest type
May take on values: CREATE, UPDATE, DELETE, AUTH, GET
string()yes
2.3state

Current status of the request
May take on values: 

ACCEPTED - pre-validation passed and request accepted
WAITING - the request is awaiting processing (depends on the execution of another request)
SUCCESSFUL - the request was processed successfully
INVALID - the request was processed with an error

string()yes
2.4date_timeDate and time of setting current status of the request (format yyyy-MM-dd'T'HH:mm:ssZ)datetimeyes
2.5errorsRequest processing errorserror[]no
2.5.1codeError codestring()yes
2.5.2messageError descriptionstring()yes
2.6warningsRequest processing warningswarning[]no
2.6.1codeWarning codestring()yes
2.6.2messageWarning descriptionstring()yes


https://api.cdek.ru/v2/webhooks/73c65d02-51a9-4423-8ee8-cc662ec3eb85


{
    "entity": {
        "uuid": "73c65d02-51a9-4423-8ee8-cc662ec3eb85"
    },
    "requests": [
        {
            "request_uuid": "72753031-0e1b-4f1d-abcc-b0bqw456ab2f",
            "type": "DELETE",
            "state": "SUCCESSFUL",
            "date_time": "2020-02-10T12:14:57+0000",
            "errors": [],
            "warnings": []
        }
    ]
}


 

© 2000—2024, Курьерская компания СДЭК