YouSend API, is a way to formalize your sendings 100% automatically. Each time your customer would place an order on your platform you automatically make its shipment on YouSend
API Documentation described below is an instrument that integrates with YouSend and synchronizes your data with our service.
Learn more how to automate logistics with our fulfilment.
Please don't be afraid of the code below. It is easy to understand to anyone who is familiar with coding. Simply email link to this page to anyone who is managing your webpage and hopefully they will make API connection with us easily. However if you will need any assitstance - please contact us and we will be happy to help!
api.Important notes.
The base URL of the api is located at https://yousend.lv/api/[_env]/v1
An examples of how to get an authentication token "Bearer authentication token".
You authenticate against the API using “Bearer authentication
The name “Bearer authentication” can be understood
as “give access to the bearer of this token.”
Bearer authentication (also called token authentication)
is an HTTP authentication scheme that involves
security tokens called bearer tokens.
*** REQUEST METHOD ***
POST
*** REQUEST URL ***
PRODUCTION URL:
https://yousend.lv/api/production/v1/auth/login;
DEVELOPMENT URL:
https://yousend.lv/api/development/v1/auth/login;
*** REQUEST HEADERS ***
$headers = [
Content-Type : application/json,
Accept : application/json
];
=============================== Example № 1 ===============================
REQUEST DATA:
{
'email' : 'YOUR_EMAIL_ADDRESS',
'password': 'YOUR_PASSWORD'
}
STATUS CODE [200] - REQUEST SUCCESS
{
"access_token" : "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImE1YTlmYzE1Z
jc1MGRhZjk3NTljZjJlOWY3NWFlMGM0OTI5NWIzNjNlODc3MTAyOGZhYjc4YmZkZDgxMWQxOGZl
YWRmNDkyMDc0ODJhNzAzIn0.eyJhdWQiOiIzIiwianRpIjoiYTVhOWZjMTVmNzUwZGFmOTc1OWN
mMmU5Zjc1YWUwYzQ5Mjk1YjM2M2U4NzcxMDI4ZmFiNzhiZmRkODExZDE4ZmVhZGY0OTIwNzQ4Mm
E3MDMiLCJpYXQiOjE1NDgzMzYxMjUsIm5iZiI6MTU0ODMzNjEyNSwi2XhwIjoxNTc5ODcyMTI1L
CJzdWIiOiIxMjAiLCJzY29wZXMiOltdfQ.DzZv_es9NbF3yjQTj3tOyNFxxBRa29TdJqbXWGBl3
c_0V_yIrNvl9qJPOStlRFLUDbDDkDRY6EtRwFhGrALv2nw2a7TWGhtBOBz2VaYiQ1cdus855lRZ
NbApYcOop4PFJkX5IgUlypefWW3RTjzayp1UdCS7UcnFB_-DPTnk90Fbb170ypgBLNwWzVAjqI_
KmSfRgjALXO4xXg6HsUD3snkgt_tzZ_-Dk_xbza67KvJ0lFPbI4pj706LbXERbjRF2a-VTP5FD8
vCXPLJxEjJNZJemC3OQ0WOcRNg2VTYpGK84rlnjqOfIVDbVehemBYLgjkHyk6ZWrYQtRcdpfKvy
qcSqfc6WDl71d93RyHG5Lz28TfckYjvRzT_sjWeb_qhRyA_gvnVM826EdggO_Oaa7kcq0hhmlm-
NL-nX1Yelz7U_Bob76slo6tESdG-V7z9CcjQ_7Jvn2DJzhcFC0tCiP-NbwepfgivGRBv65pFxs-
llhDXziNFubw8Ax3JvAXR9VRhNobO935svY9SlEcUCOrlERJ0AbE-RUSorm7-oFX5XCh9uCRsub
VAuvx0t5TkEsNdA_XSLJZXQcLizugs_hWIljEuBqTNInp7o6KisU_MC7mrjiPbQQYsawx1CR3m2
ZSt4ONcQP28wgv2MItG7AA3I78m3uY54YubKh0ofh8",
"token_type":"Bearer",
"expires_at":"2024-01-30 00:00:00"
}
=============================== Example №2 ===============================
REQUEST DATA:
{
'email' : 'YOUR_EMAIL_ADDRESS',
'password': 'YOUR_PASSWORD'
}
STATUS CODE [401] - NOT AUTHORIZED
{
"message" : "Unauthorized"
}
The base URL of the api is located at https://yousend.lv/api/[_env]/v1
Example for getting prices for delivery services.
*** REQUEST METHOD ***
GET
*** REQUEST URL ***
PRODUCTION URL:
https://yousend.lv/api/production/v1/services/calculate;
DEVELOPMENT URL:
https://yousend.lv/api/development/v1/services/calculate;
*** REQUEST HEADERS ***
$headers = [
Content-Type : application/json,
Accept : application/json
];
=============================== Austria 4690 2 packages ===============================
- 2 Kg [27 x 28 x 29]
- 3 Kg [50 x 50 x 50]
REQUEST URL:
https://yousend.lv/api/development/v1/services/calculate?zip_code=4690&weight%5B%5D=2
&length%5B%5D=27&width%5B%5D=28&height%5B%5D=29&weight%5B%5D=3&length%5B%5D=50
&width%5B%5D=50&height%5B%5D=50&country_code=at&package_type=1&send_adr=0
STATUS CODE [200] - REQUEST SUCCESS
{
"type": "success",
"message": "OK",
"data": [
{
"package_type": 1,
"service_code": "ups_standard",
"service_name": "UPS Standard",
"final_price_without_tax": "52.68",
"final_price_with_tax": "63.74",
"is_eu": 1,
"service_type": 2,
"zip_code": "4690",
"country_code": "at",
"dimensions": [
{
"weight": "2",
"length": "27",
"height": "29",
"width": "28"
},
{
"weight": "3",
"length": "50",
"height": "50",
"width": "50"
}
],
"delivery_days": "5-6"
},
{
"package_type": 1,
"service_code": "ups_express_saver",
"service_name": "UPS Express Saver",
"final_price_without_tax": "144.71",
"final_price_with_tax": "175.10",
"is_eu": 1,
"service_type": 1,
"zip_code": "4690",
"country_code": "at",
"dimensions": [
{
"weight": "2",
"length": "27",
"height": "29",
"width": "28"
},
{
"weight": "3",
"length": "50",
"height": "50",
"width": "50"
}
],
"delivery_days": "1-2"
}
]
}
=============================== Austria 4690 1 packages ===============================
- 2 Kg [27 x 28 x 29]
REQUEST URL:
https://yousend.lv/api/development/v1/services/calculate?zip_code=4690&weight%5B%5D=2
&length%5B%5D=27&width%5B%5D=28&height%5B%5D=29&country_code=at&package_type=1&send_adr=0
STATUS CODE [200] - REQUEST SUCCESS
{
"type": "success",
"message": "OK",
"data": [
{
"package_type": 1,
"service_code": "ups_standard",
"service_name": "UPS Standard",
"final_price_without_tax": "34.18",
"final_price_with_tax": "41.36",
"is_eu": 1,
"service_type": 2,
"zip_code": "4690",
"country_code": "at",
"dimensions": [
{
"weight": "2",
"length": "27",
"height": "29",
"width": "28"
}
],
"delivery_days": "5-6"
},
{
"package_type": 1,
"service_code": "ups_express_saver",
"service_name": "UPS Express Saver",
"final_price_without_tax": "50.27",
"final_price_with_tax": "60.83",
"is_eu": 1,
"service_type": 1,
"zip_code": "4690",
"country_code": "at",
"dimensions": [
{
"weight": "2",
"length": "27",
"height": "29",
"width": "28"
}
],
"delivery_days": "1-2"
},
{
"package_type": 1,
"service_code": "dpd_classic",
"service_name": "DPD Classic",
"final_price_without_tax": "23.36",
"final_price_with_tax": "28.27",
"is_eu": 1,
"service_type": 2,
"zip_code": "4690",
"country_code": "at",
"dimensions": [
{
"weight": "2",
"length": "27",
"height": "29",
"width": "28"
}
],
"delivery_days": "4-5"
}
]
}
=============================== Austria 4690 1 envelope ===============================
- 0.5 Kg [27 x 28 x 29]
REQUEST URL:
https://yousend.lv/api/development/v1/services/calculate?&zip_code=4690
&weight%5B%5D=0.5&country_code=at&package_type=2&send_adr=0
STATUS CODE [200] - REQUEST SUCCESS
{
"type": "success",
"message": "OK",
"data": [
{
"package_type": 2,
"service_code": "ups_express_saver",
"service_name": "UPS Express Saver",
"final_price_without_tax": "33.46",
"final_price_with_tax": "40.49",
"is_eu": 1,
"service_type": 1,
"zip_code": "4690",
"country_code": "at",
"dimensions": [
{
"weight": "0.5",
"length": 10,
"height": 10,
"width": 10
}
],
"delivery_days": "1-2"
},
{
"package_type": 2,
"service_code": "ups_express_envelope",
"service_name": "UPS Express Envelope",
"final_price_without_tax": "33.46",
"final_price_with_tax": "40.49",
"is_eu": 1,
"service_type": 1,
"zip_code": "4690",
"country_code": "at",
"dimensions": [
{
"weight": "0.5",
"length": 10,
"height": 10,
"width": 10
}
],
"delivery_days": "1-2"
}
]
}
=============================== Austria 4690d 2 packages ===============================
- 2 Kg [27 x 28 x 29]
- 3 Kg [50 x 50 x 50]
REQUEST URL:
https://yousend.lv/api/development/v1/services/calculate?zip_code=4690d&weight%5B%5D=2
&length%5B%5D=27&width%5B%5D=28&height%5B%5D=29&weight%5B%5D=3&length%5B%5D=50
&width%5B%5D=50&height%5B%5D=50&country_code=at&package_type=1&send_adr=0
STATUS CODE [422] - VALIDATION ERROR
{
"type": "error",
"message": "An exception has been raised as a result of client data",
"errors": {
"zip_code": [
"Available post code format(s):0000"
]
}
}
=============================== Austria 4690 2 packages ===============================
- 2 Kg [27 x 28 x 29]
- 3 Kg [50 x 50 x 50]
REQUEST URL:
https://yousend.lv/api/development/v1/services/calculate?zip_code=4690d&weight%5B%5D=2
&length%5B%5D=27&width%5B%5D=28&height%5B%5D=29&weight%5B%5D=3&length%5B%5D=50
&width%5B%5D=50&height%5B%5D=50&country_code=at&parcel_copy_id=&package_type=3&send_adr=0
STATUS CODE [422] - VALIDATION ERROR
{
"type": "error",
"message": "An exception has been raised as a result of client data",
"errors": {
"package_type": [
"The selected package type is invalid.",
"The package type may not be greater than 2."
]
}
}
=============================== Lithuania LT-17248 1 packages ===============================
- 2 Kg [27 x 28 x 29]
If you want to use DPD "Cash On Delivery" service.
Please specify the "Cash to be collected" price in the "parcel_price" field.
To get the current and final cost for the DPD Cash service.
REQUEST URL:
https://yousend.lv/api/development/v1/services/calculate?zip_code=LT-17248&weight%5B%5D=2
&length%5B%5D=27&width%5B%5D=28&height%5B%5D=29&country_code=LT&package_type=1&send_adr=0&parcel_price=129.99
STATUS CODE [200] - REQUEST SUCCESS
{
"type": "success",
"message": "OK",
"data": [
{
"package_type": 1,
"service_code": "ups_standard",
"service_name": "UPS Standard",
"final_price_without_tax": "30.28",
"final_price_with_tax": "36.64",
"is_eu": 1,
"service_type": 2,
"zip_code": "LT-17248",
"country_code": "LT",
"dimensions": [
{
"weight": "2",
"length": "27",
"height": "29",
"width": "28"
}
],
"delivery_days": "2-3"
},
{
"package_type": 1,
"service_code": "ups_express_saver",
"service_name": "UPS Express Saver",
"final_price_without_tax": "42.79",
"final_price_with_tax": "51.78",
"is_eu": 1,
"service_type": 1,
"zip_code": "LT-17248",
"country_code": "LT",
"dimensions": [
{
"weight": "2",
"length": "27",
"height": "29",
"width": "28"
}
],
"delivery_days": "1-2"
},
{
"package_type": 1,
"service_code": "dpd_classic",
"service_name": "DPD Classic",
"final_price_without_tax": "12.04",
"final_price_with_tax": "14.57",
"is_eu": 1,
"service_type": 2,
"zip_code": "LT-17248",
"country_code": "lt",
"dimensions": [
{
"weight": "2",
"length": "27",
"height": "29",
"width": "28"
}
],
"delivery_days": "1-2"
},
{
"package_type": 1,
"service_code": "ups_express",
"service_name": "UPS Express",
"final_price_without_tax": "49.55",
"final_price_with_tax": "59.96",
"is_eu": 1,
"service_type": 1,
"zip_code": "LT-17248",
"country_code": "LT",
"dimensions": [
{
"weight": "2",
"length": "27",
"height": "29",
"width": "28"
}
],
"delivery_days": "1-2"
},
{
"package_type": 1,
"service_code": "dpd_cod",
"service_name": "DPD Cash On Delivery",
"final_price_without_tax": "18.64",
"final_price_with_tax": "22.55",
"is_eu": 1,
"service_type": 2,
"zip_code": "LT-17248",
"country_code": "lt",
"dimensions": [
{
"weight": "2",
"length": "27",
"height": "29",
"width": "28"
}
],
"delivery_days": "1-2"
}
]
}
The base URL of the api is located at https://yousend.lv/api/[_env]/v1
An examples of how to create a new order.
*** REQUEST METHOD ***
POST
*** REQUEST METHOD ***
PRODUCTION URL:
https://yousend.lv/api/production/v1/services/order-store
DEVELOPMENT URL:
https://yousend.lv/api/development/v1/services/order-store
*** REQUEST HEADERS ***
$headers = [
Content-Type : application/json,
Accept : application/json
Authorization : Bearer 'TOKEN'
];
=============================== Austria 4690 2 packages ===============================
- 2 kg [27 x 28 x 29]
- 3 kg [50 x 50 x 50]
REQUEST DATA:
{
"send_adr":"1",
"parcel_price":"8.99",
"parcel_currency":"1", // 0: EUR, 1: USD, 2: PLN
"parcel_description":"Books",
"parcel_sender":"Petter Parker",
"parcel_pickup_address":"Marupes 56",
"parcel_pickup_date":"2020-01-31 17:26:24",
"reason_for_export":"sold",
"weight":[
"2","3"
],
"length":[
"27","50"
],
"height":[
"28","50"
],
"width":[
"29","50"
],
"recipient_house_number":"23",
"recipient_address_1":"test 5-6",
"recipient_company_name":"SIA GT",
"recipient_city":"AMPASS",
"recipient_state_or_province" : "",
"zip_code":"4690",
"country_code":"at",
"recipient_name":"Petter",
"recipient_phone":"29878473829",
"recipient_email":"petterparker@gmail.com",
"package_type":"1",
"service_code":"ups_express_saver"
}
STATUS CODE [200] - REQUEST SUCCESS
{
"type": "success",
"message": "Shipment has been successfully created",
"data": {
"shipment_id": 27837
}
}
=============================== Austria 4690 1 packages ===============================
- 2 kg [27 x 28 x 29]
REQUEST DATA:
{
"send_adr":"1",
"parcel_price":"8.99",
"parcel_currency":"1", // 0: EUR, 1: USD, 2: PLN
"parcel_description":"Books",
"parcel_sender":"Petter Parker",
"parcel_pickup_address":"Marupes 56",
"parcel_pickup_date":"2020-01-31 17:26:24",
"reason_for_export":"sold",
"weight":[
"2"
],
"length":[
"27"
],
"height":[
"28"
],
"width":[
"29"
],
"recipient_house_number":"23",
"recipient_address_1":"test 5-6",
"recipient_company_name":"SIA GT",
"recipient_city":"AMPASS",
"recipient_state_or_province":"",
"zip_code":"4690",
"country_code":"at",
"recipient_name":"Petter",
"recipient_phone":"29878473829",
"recipient_email":"petterparker@gmail.com",
"package_type":"1",
"service_code":"ups_express_saver"
}
STATUS CODE [200] - REQUEST SUCCESS
{
"type": "success",
"message": "Shipment has been successfully created",
"data": {
"shipment_id": 27838
}
}
=============================== Austria 4690 1 envelope ===============================
- 0.5 kg
REQUEST DATA:
{
"send_adr":"1",
"parcel_price":"8.99",
"parcel_currency":"1", // 0: EUR, 1: USD, 2: PLN
"parcel_description":"Books",
"parcel_sender":"Petter Parker",
"parcel_pickup_address":"Marupes 56",
"parcel_pickup_date":"2020-01-31 17:26:24",
"reason_for_export":"sold",
"weight":[
"0.5"
],
"recipient_house_number":"23",
"recipient_address_1":"test 5-6",
"recipient_company_name":"SIA GT",
"recipient_city":"AMPASS",
"recipient_state_or_province":"",
"zip_code":"4690",
"country_code":"at",
"recipient_name":"Petter",
"recipient_phone":"29878473829",
"recipient_email":"petterparker@gmail.com",
"package_type":"2",
"service_code":"ups_express_saver"
}
STATUS CODE [200] - REQUEST SUCCESS
{
"type": "success",
"message": "Shipment has been successfully created",
"data": {
"shipment_id": 27839
}
}
=============================== Austria 4690d 2 packages ===============================
- 2 kg [27 x 28 x 29]
- 3 kg [50 x 50 x 50]
REQUEST DATA:
{
"send_adr":"1",
"parcel_price":"8.99",
"parcel_currency":"1", // 0: EUR, 1: USD, 2: PLN
"parcel_description":"Books",
"parcel_sender":"Petter Parker",
"parcel_pickup_address":"Marupes 56",
"parcel_pickup_date":"2020-01-31 17:26:24",
"reason_for_export":"sold",
"weight":[
"2","3"
],
"length":[
"27","50"
],
"height":[
"28","50"
],
"width":[
"29","50"
],
"recipient_house_number":"23",
"recipient_address_1":"test 5-6",
"recipient_company_name":"SIA GT",
"recipient_city":"AMPASS",
"recipient_state_or_province":"",
"zip_code":"4690d",
"country_code":"at",
"recipient_name":"Petter",
"recipient_phone":"29878473829",
"recipient_email":"petterparker@gmail.com",
"package_type":"1",
"service_code":"ups_express_saver"
}
STATUS CODE [422] - VALIDATION ERROR
{
"type": "error",
"message": "An exception has been raised as a result of client data",
"errors": {
"zip_code": [
"Available post code format(s):0000"
]
}
}
=============================== Austria 4690 1 envelope ===============================
- 0.5 kg
REQUEST DATA:
{
"send_adr":"1",
"parcel_currency":"1", // 0: EUR, 1: USD, 2: PLN
"parcel_description":"Books",
"parcel_sender":"Petter Parker",
"parcel_pickup_address":"Marupes 56",
"parcel_pickup_date":"2020-01-31 17:26:24",
"reason_for_export":"sold",
"weight":[
"0.5"
],
"recipient_house_number":"23",
"recipient_address_1":"test 5-6",
"recipient_city":"AMPASS",
"recipient_state_or_province":"22222",
"zip_code":"4690",
"recipient_name":"Petter",
"package_type":"2",
"service_code":"ups_express_saver"
}
STATUS CODE [422] - VALIDATION ERROR
{
"type": "error",
"message": "An exception has been raised as a result of client data",
"errors": {
"recipient_phone": [
"A recipient Phone number is required, Please add it!"
],
"recipient_state_or_province": [
"The state or province may not be greater than 4 characters."
],
"country_code": [
"A recipient Country is required, Please add it!"
],
"parcel_price": [
"A parcel price is required, Please add it!"
]
}
}
=============================== Austria 4690 2 envelopes ===============================
- 2 kg
- 3 kg
REQUEST DATA:
{
"send_adr":"1",
"parcel_currency":"1", // 0: EUR, 1: USD, 2: PLN
"parcel_description":"Books",
"parcel_sender":"Petter Parker",
"parcel_pickup_address":"Marupes 56",
"parcel_pickup_date":"2020-01-31 17:26:24",
"reason_for_export":"sold",
"weight":[
"2.0", "3.0"
],
"recipient_house_number":"23",
"recipient_address_1":"test 5-6",
"recipient_city":"AMPASS",
"recipient_state_or_province":"TILON",
"zip_code":"4690",
"recipient_name":"Petter",
"package_type":"2",
"service_code":"ups_express_saver"
}
STATUS CODE [422] - VALIDATION ERROR
{
"type": "error",
"message": "An exception has been raised as a result of client data",
"errors": {
"recipient_phone": [
"A recipient Phone number is required, Please add it!"
],
"recipient_state_or_province": [
"The state or province may not be greater than 4 characters."
],
"country_code": [
"A recipient Country is required, Please add it!"
],
"parcel_price": [
"A parcel price is required, Please add it!"
]
}
}
=============================== Empty data ===============================
REQUEST DATA:
{
}
STATUS CODE [422] - VALIDATION ERROR
{
"type": "error",
"message": "An exception has been raised as a result of client data",
"errors": {
"send_adr": [
"The ADR field is required."
],
"recipient_name": [
"A recipient name is required, Please add it!"
],
"recipient_phone": [
"A recipient Phone number is required, Please add it!"
],
"recipient_address_1": [
"A recipient delivery address is required, Please add it!"
],
"recipient_city": [
"A recipient City is required, Please add it!"
],
"country_code": [
"A recipient Country is required, Please add it!"
],
"zip_code": [
"The zip code field is required."
],
"parcel_price": [
"A parcel price is required, Please add it!"
],
"service_code": [
"The service code field is required."
],
"reason_for_export": [
"The validation.attribute.reason_for_export field is required."
],
"parcel_currency": [
"Please select a currency type!"
],
"parcel_pickup_date": [
"A pickup date is required, Please add it!"
],
"parcel_description": [
"A parcel description is required, Please add it!"
],
"parcel_pickup_address": [
"A parcel pickup address is required, Please add it!"
]
}
}
=============================== Austria 4690d 2 packages ===============================
- 2 kg [27 x 28 x 29]
- 3 kg [50 x 50 x 50]
REQUEST DATA:
{
"send_adr":"1",
"parcel_price":"8.99",
"parcel_currency":"1", // 0: EUR, 1: USD, 2: PLN
"parcel_description":"Books",
"parcel_sender":"Petter Parker",
"parcel_pickup_address":"Marupes 56",
"parcel_pickup_date":"2020-01-31 17:26:24",
"reason_for_export":"sold",
"weight":[
"2","3"
],
"length":[
"27"
],
"height":[
"28"
],
"width":[
"29","50"
],
"recipient_house_number":"23",
"recipient_address_1":"test 5-6",
"recipient_company_name":"SIA GT",
"recipient_city":"AMPASS",
"recipient_state_or_province":"TILON",
"zip_code":"4690d",
"country_code":"at",
"recipient_name":"Petter",
"recipient_phone":"29878473829",
"recipient_email":"petterparker@gmail.com",
"package_type":"1",
"service_code":"ups_express_saver"
}
STATUS CODE [422] - VALIDATION ERROR
{
"type": "error",
"message": "An exception has been raised as a result of client data",
"errors": {
"recipient_state_or_province": [
"The state or province may not be greater than 4 characters."
]
}
}
=============================== Lithuania LT-17248 1 packages ===============================
- 2 Kg [27 x 28 x 29]
If you want to use DPD "Cash On Delivery" service.
Please specify the "Cash to be collected" price in the "parcel_price" field.
To get the current and final cost for the DPD Cash service.
REQUEST DATA:
{
"send_adr":"1",
"parcel_price":"129.99",
"parcel_currency":"1", // 0: EUR, 1: USD, 2: PLN
"parcel_description":"Books",
"parcel_sender":"Petter Parker",
"parcel_pickup_address":"Marupes 56",
"parcel_pickup_date":"2019-01-31 17:26:24",
"reason_for_export":"sold",
"weight":[
"2"
],
"length":[
"27"
],
"height":[
"28"
],
"width":[
"29"
],
"recipient_house_number":"23",
"recipient_address_1":"test 5-6",
"recipient_company_name":"SIA GT",
"recipient_city":"AMPASS",
"recipient_state_or_province":"",
"zip_code":"LT-17248",
"country_code":"lt",
"recipient_name":"Petter",
"recipient_phone":"29878473829",
"recipient_email":"petterparker@gmail.com",
"package_type":"1",
"service_code":"dpd_cod"
}
STATUS CODE [200] - REQUEST SUCCESS
{
"type": "success",
"message": "Shipment has been successfully created",
"data": {
"shipment_id": 27839
}
}
When the parcel is confirmed in the YouSend system, the parcel tracking number is assigned to your registered parcel. In order for you to receive a tracking number at the same moment, you need to specify an additional field "callback_success_url" - full address URL, to which a client will get information about shipment, in "New Shipment Request".
Your script must return the message "OK". Only then our system will register, that information about the shipment has been successfully received.
The base URL of the api is located at https://yousend.lv/api/[_env]/v1
An examples of how to create a new order with a callback url.
*** REQUEST METHOD ***
POST
*** REQUEST METHOD ***
PRODUCTION URL:
https://yousend.lv/api/production/v1/services/order-store
DEVELOPMENT URL:
https://yousend.lv/api/development/v1/services/order-store
*** REQUEST HEADERS ***
$headers = [
Content-Type : application/json,
Accept : application/json
Authorization : Bearer 'TOKEN'
];
=============================== Austria 4690 2 packages ===============================
- 2 kg [27 x 28 x 29]
- 3 kg [50 x 50 x 50]
REQUEST DATA:
{
"send_adr":"1",
"parcel_price":"8.99",
"parcel_currency":"1", // 0: EUR, 1: USD, 2: PLN
...
...
...
"callback_success_url": "https://my-site.com/shipment" // Full address URL
...
...
...
"package_type":"1",
"service_code":"ups_express_saver"
}
Below is an example of what shipping data will be sent from the YouSend API to your callback URL, which was specified in the field "callback_success_url" in request "New Shipment Request".
An example of a request with the data that will be sent from the YouSend API.
*** REQUEST METHOD ***
GET
*** REQUEST HEADERS ***
$headers = [
Content-Type : application/json,
Accept : application/json
];
=============================== Example №1 ===============================
REQUEST URL: Example with 3 parcel tracking numbers
<<_CALLBACK_URL>>?shipment_id=27854&tracking_numbers=1Z883V1R6899886732|1Z883V1R6899920346|1Z883V1R6897974757
=============================== Example №2 ===============================
REQUEST URL: Example with 1 parcel tracking numbers
<<_CALLBACK_URL>>?shipment_id=27854&tracking_numbers=1Z883V1R6899886732
If the callback request was successfully processed, you need to return a JSON Response with the message "OK", to inform us about the request that has been successfully received. If there is no answer "OK", the message will be sent 3 times, every request at the beginning of the hour. Below is an example of what JSON data your script should return upon successful completion.
An example of a response to a YouSend API request,
if the request was successfully processed in your system.
*** REQUEST HEADERS ***
$headers = [
Content-Type : application/json,
Accept : application/json
];
=============================== Example №1 ===============================
REQUEST DATA:
{
"message":"OK" // case insensitive string
}
The base URL of the api is located at https://yousend.lv/api/[_env]/v1
An examples how to get a list of personal orders.
*** REQUEST METHOD ***
GET
*** REQUEST URL ***
PRODUCTION URL:
https://yousend.lv/api/production/v1/services/shipments;
DEVELOPMENT URL:
https://yousend.lv/api/development/v1/services/shipments;
*** REQUEST HEADERS ***
$headers = [
Content-Type : application/json,
Accept : application/json
Authorization : Bearer 'TOKEN'
];
====================================== Example №1 ======================================
Request URL:
https://yousend.lv/api/development/v1/services/shipments?date_form=2022-01-01&date_to=2022-01-18
STATUS CODE [200] - REQUEST SUCCESS
{
"type": "success",
"message": "OK",
"shipment_ids": [
274040,
274041,
....
....
....
274060
]
}
====================================== Example №2 ======================================
REQUEST URL:
https://yousend.lv/api/development/v1/services/shipments??date_form=2022-01-01&date_to=2022-01-01
STATUS CODE [200] - REQUEST SUCCESS
{
"type": "success",
"message": "OK",
"shipment_ids": []
}
====================================== Example №3 ======================================
REQUEST URL:
https://yousend.lv/api/development/v1/services/shipments??date_form=2022-01-01&date_to=22022-01-18
STATUS CODE [422] - VALIDATION ERROR
{
"message": "The given data was invalid.",
"errors": {
"date_to": [
"The date to is not a valid date.",
"The date to does not match the format Y-m-d.",
"The date to may not be greater than 10 characters."
]
}
}
====================================== Example №4 ======================================
REQUEST URL:
https://yousend.lv/api/development/v1/services/shipments??date_form=2022-01-01&date_to=2022-01-18
STATUS CODE [500] - SERVER ERROR
{
"message": "A server error has occurred. Please inform the administrator."
}
The base URL of the api is located at https://yousend.lv/api/[_env]/v1
An examples how to get order details.
*** REQUEST METHOD ***
GET
*** REQUEST URL ***
PRODUCTION URL:
https://yousend.lv/api/production/v1/services/shipment/{id};
DEVELOPMENT URL:
https://yousend.lv/api/development/v1/services/shipment/{id};
*** REQUEST HEADERS ***
$headers = [
Content-Type : application/json,
Accept : application/json
Authorization : Bearer 'TOKEN'
];
====================================== Example №1 ======================================
REQUEST URL:
https://yousend.lv/api/development/v1/services/shipment/27850
STATUS CODE [200] - REQUEST SUCCESS
{
"shipment": {
"id": 27850,
"tracking_numbers": [],
"reference_number": null,
"service": {
"name": "DPD Cash On Delivery",
"code": "dpd_cod"
},
"parcel": {
"sender": "Petter Parker",
"price": "29.99",
"currency": 1,
"description": "Books",
"pickup_address": "Test 56",
"pickup_date": "2019-01-31 17:26:24",
"dimensions": [
{
"weight": "2",
"length": "27",
"height": "28",
"width": "29"
}
]
},
"recipient": {
"country": {
"name": "Lithuania",
"code": "LT"
},
"city": "TEST",
"zip_code": "LT-17248",
"state_or_province": "",
"address_1": "test 5-6",
"address_2": "",
"address_3": "",
"company_name": "SIA GT",
"name": "Petter",
"email": "petterparker@gmail.com",
"phone": "20202020"
},
"service_price": {
"without_tax": "430.41",
"with_tax": "520.80"
}
}
}
====================================== Example №2 ======================================
REQUEST URL:
https://yousend.lv/api/development/v1/services/shipment/278502
STATUS CODE [404] - RESOURCE NOT FOUND
{
"type": "error",
"message": "Resource not found"
}
====================================== Example №3 ======================================
REQUEST URL:
https://yousend.lv/api/production/v1/services/shipment/27830
STATUS CODE [422] - VALIDATION ERROR
{
"message": "Shipment not found or you don't have permission to view the order"
}
====================================== Example №4 ======================================
REQUEST URL:
https://yousend.lv/api/production/v1/services/shipment/27830
STATUS CODE [500] - SERVER ERROR
{
"message": "A server error has occurred. Please inform the administrator."
}