Skip to main content

Zonos API

zonos api integration for deno




Configuration

Initialize

import { Zonos } from "https://deno.land/x/zonos_api/mod.ts";

const zonos = new Zonos({
  account_number: "",
  api_key: ""
});

Note: register for an account_number and api_key at Zonos



Change API version

/* 
    Version: string | number 
*/
zonos.setVersion(1);

This can also be set directly on the Zonos class initialization with: apiVersion: '1'.



Set Cors Proxy

some endpoints do not support cross origin if called from the front end. In that case you can set a cors proxy to pass the request through.

zonos.setCorsProxy("https://cors.zonos.com/");

This can also be set directly on the Zonos class initialization with: corsProxy: 'https://cors.zonos.com/'.

Note: http://cors.zonos.com/ is not currently live. Use your own cors proxy for now.



Direct API Call

zonos.directApiCall(
    "PATH",
    { 
        "json": "body"
    },
    "POST|GET|PUT|DELETE"
);

Note: see Zonos Docs for more information on our supported REST endpoints.




Orders


Get Order

Returns a single orders details

By zonos order id:

/* 
    id: string | number
    isReferenceId?: boolean
*/
zonos.getOrder("12312312");

By refrerence id:

/* 
    id: string | number
    isReferenceId?: boolean
*/
zonos.getOrder("order_bt23", true);

Additonal Docs: Order Details


Get Orders

Returns a list of orders that have been created from your checkouts. (requires api version 1)

/* 
    sinceDate: string - yyyyMMdd
    statuses?: boolean 
*/
zonos.getOrders("20220912", true);

Update Order Status

Updates an orders status in Zonos Dashboard

/* 
    orderId: string | number
    status: string 
*/
zonos.updateOrderStatus("152352", "ready");

Allowed statuses: preparing - ready - printed - cancelled - completed


Update Order Number

Adds a merchant order id to the order.

    /*
        orderId: string | number 
        merchantOrderId: string | number
    */
    zonos.updateOrderNumber("152352", "bc_123");

merchantOrderId should match the order id used in your ecomm platform


Add/Update Order Tracking Numbers

Add or update a tracking number to the order.

/*
    orderId: string | number
    trackingNumber: string
*/
zonos.updateOrderTracking("152352", "fedex_tracking_number");

this will automatically mark the order as completed in Zonos Dashboard


Checkout


Create a Checkout

creates a checkout and returns a url for the customer to access the checkout

/*
    cart: ZonosCart
    countryCode?: string
*/
zonos.createCheckout(cart, "CA");

cart must be json format with at least the rquired fields shown on the ZonosCart type