Skip to main content
POST
/
shipping
/
shipments
/
{id}
/
cancel
Cancel shipment
curl --request POST \
  --url https://api.bitbybit.studio/customer/api/open/v1/shipping/shipments/{id}/cancel \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "reason": "Customer cancelled the order"
}
'
import requests

url = "https://api.bitbybit.studio/customer/api/open/v1/shipping/shipments/{id}/cancel"

payload = { "reason": "Customer cancelled the order" }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({reason: 'Customer cancelled the order'})
};

fetch('https://api.bitbybit.studio/customer/api/open/v1/shipping/shipments/{id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.bitbybit.studio/customer/api/open/v1/shipping/shipments/{id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'reason' => 'Customer cancelled the order'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.bitbybit.studio/customer/api/open/v1/shipping/shipments/{id}/cancel"

payload := strings.NewReader("{\n \"reason\": \"Customer cancelled the order\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.bitbybit.studio/customer/api/open/v1/shipping/shipments/{id}/cancel")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"reason\": \"Customer cancelled the order\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.bitbybit.studio/customer/api/open/v1/shipping/shipments/{id}/cancel")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reason\": \"Customer cancelled the order\"\n}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "id": "<string>",
    "orderId": "<string>",
    "providerLabel": "<string>",
    "name": "<string>",
    "fee": 123,
    "currency": "<string>",
    "serviceName": "<string>",
    "selectedExpedition": "<string>",
    "selectedDelivery": "<string>",
    "courierGroup": "<string>",
    "bikeFuelType": "<string>",
    "pickupSchedule": "2023-11-07T05:31:56Z",
    "storeLocationId": "<string>",
    "sender": {
      "name": "<string>",
      "phone": "<string>",
      "email": "<string>",
      "address": "<string>",
      "notes": "<string>",
      "city": "<string>",
      "province": "<string>",
      "country": "<string>",
      "zip": "<string>",
      "kecamatan": "<string>",
      "kecamatanId": 123,
      "kelurahan": "<string>",
      "kelurahanId": 123,
      "coordinates": {
        "lat": 0,
        "lng": 0
      }
    },
    "delivery": {
      "name": "<string>",
      "phone": "<string>",
      "email": "<string>",
      "address": "<string>",
      "notes": "<string>",
      "city": "<string>",
      "province": "<string>",
      "country": "<string>",
      "zip": "<string>",
      "kecamatan": "<string>",
      "kecamatanId": 123,
      "kelurahan": "<string>",
      "kelurahanId": 123,
      "coordinates": {
        "lat": 0,
        "lng": 0
      }
    },
    "package": {
      "weight": 123,
      "length": 123,
      "width": 123,
      "height": 123,
      "itemName": "<string>",
      "itemType": "<string>",
      "itemValue": 123,
      "itemQty": 123,
      "notes": "<string>"
    },
    "driver": {
      "name": "<string>",
      "phone": "<string>",
      "photo": "<string>",
      "licensePlate": "<string>"
    },
    "insurance": true,
    "insuranceFee": 123,
    "insuranceAmount": 123,
    "discountAmount": 123,
    "discountPercentage": 123,
    "distance": 123,
    "trackingUrl": "<string>",
    "awb": "<string>",
    "orderNo": "<string>",
    "bookingId": "<string>",
    "pickupNumber": "<string>",
    "paymentId": "<string>",
    "paymentStatus": "<string>",
    "statusCode": 123,
    "cancellationReason": "<string>",
    "cancelledBy": "<string>",
    "cancelledSource": "<string>",
    "eventTimestamp": "<string>"
  }
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "origin.districtId is required for KiriminAja Express"
}
}
{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key"
}
}
{
"error": {
"code": "NOT_FOUND",
"message": "Shipment not found"
}
}

Authorizations

x-api-key
string
header
required

API key for authentication. Create one in Settings > Developer. The key must have the BITCRM product scope and an orders resource scope; required action depends on the endpoint (READ, WRITE, or DELETE).

Path Parameters

id
string
required

Body

application/json
reason
string

Human-readable cancellation reason (max 500 chars).

Maximum string length: 500

Response

Cancelled.

data
object