Page tree
Skip to end of metadata
Go to start of metadata

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 - order status events
PRINT_FORM - print forms readiness

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
Sample Request
{
    "url":"https://webhook.site",
    "type":"ORDER_STATUS"
}
Sample Response
{
    "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+0700",
            "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
Sample Request
https://api.cdek.ru/v2/webhooks/73c65d02-51a9-4423-8ee8-cc662ec3eb85
Sample Response
{
    "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+0700",
            "errors": [],
            "warnings": []
        }
    ]
}

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
Sample Request
https://api.cdek.ru/v2/print/orders/72753031-d302-48c5-8219-f3bb2a4b1f7b
Sample Response
{
    "entity": {
        "uuid": "72753031-d302-48c5-8219-f3bb2a4b1f7b",
        "orders": [
            {
                "order_uuid": "72753031-ebf7-4f15-8d23-dc6951808d69"
            }
        ],
        "copy_count": 2,
        "statuses": [
            {
                "code": "ACCEPTED",
                "name": "Принят",
                "date_time": "2020-02-10T12:26:11+0700"
            },
            {
                "code": "PROCESSING",
                "name": "Формируется",
                "date_time": "2020-02-10T12:26:11+0700"
            }
        ],
        "errors": [],
        "warnings": []
    },
    "requests": [
        {
            "errors": [],
            "warnings": []
        }
    ]
}}

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 - order status events
PRINT_FORM - print forms readiness

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
Sample Request
{
    "url":"https://webhook.site",
    "type":"ORDER_STATUS"
}
Sample Response
{
    "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+0700",
            "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.3stateCurrent status of the request
May take on values: ACCEPTED, WAITING, SUCCESSFUL, INVALID
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
Sample Request
https://api.cdek.ru/v2/webhooks/73c65d02-51a9-4423-8ee8-cc662ec3eb85
Sample Response
{
    "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+0700",
            "errors": [],
            "warnings": []
        }
    ]
}

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
Sample Request
https://api.cdek.ru/v2/print/orders/72753031-d302-48c5-8219-f3bb2a4b1f7b
Sample Response
{
    "entity": {
        "uuid": "72753031-d302-48c5-8219-f3bb2a4b1f7b",
        "orders": [
            {
                "order_uuid": "72753031-ebf7-4f15-8d23-dc6951808d69"
            }
        ],
        "copy_count": 2,
        "statuses": [
            {
                "code": "ACCEPTED",
                "name": "Принят",
                "date_time": "2020-02-10T12:26:11+0700"
            },
            {
                "code": "PROCESSING",
                "name": "Формируется",
                "date_time": "2020-02-10T12:26:11+0700"
            }
        ],
        "errors": [],
        "warnings": []
    },
    "requests": [
        {
            "errors": [],
            "warnings": []
        }
    ]
}}
  • No labels