# Connect Shiprocket to Avox

> Connect Shiprocket with an API user to track shipments by AWB or order ID, check cash on delivery orders, create returns, and get pickup, delivery, NDR and RTO updates in Avox as they happen.

Source: https://docs.theavoxai.com/connections/apps/shiprocket

Connect your Shiprocket account and your team can track any shipment inside Avox, next to the chats.
Automations can look up where an order is, check what a cash on delivery order still has to collect,
and create a return for a delivered order. With one extra step in Shiprocket, Avox also hears every
scan as it happens: picked up, in transit, out for delivery, delivered, a failed delivery (NDR) or a
parcel coming back to you (RTO).

## What Avox can and cannot do with Shiprocket

Avox can:

- track a shipment by its AWB number or by your order ID, with every scan, newest first;
- tell whether an order is cash on delivery and exactly how much the courier collects;
- create a return for an order that was delivered;
- receive tracking updates from Shiprocket when you turn on its webhook.

Avox cannot:

- create, ship or cancel orders. Do that in Shiprocket ([AVX-3725](https://docs.theavoxai.com/error-codes/avx-3725) on the
  Shipments pages);
- create a return before the order is delivered ([AVX-3742](https://docs.theavoxai.com/error-codes/avx-3742));
- choose which shipments Shiprocket sends updates for. Shiprocket sends them for every shipment in your
  account, also the ones Avox didn't touch.

## What you need before you start

- A Shiprocket account where you can open **Settings**, **API**.
- An email address only for Avox. Shiprocket's API user can't use the email you sign in with.
- A plan with room for another connected app, and the **Manage connected apps** permission in
  **Settings > Switchboard** (Admins have it; an Admin can give it to a Manager).

## Connect Shiprocket

**1. Make an API user in Shiprocket**

In Shiprocket open **Settings**, **API**, **Configure** and click **Create an API User**. Use an email
address that isn't the one you sign in with, give it a password, and allow every module if Shiprocket
asks.

**2. Open Shiprocket in Apps**

In Avox open **Apps** in the sidebar, then **Shiprocket**, click **Connect**, read **What Avox can do**
and click **Continue**.

**3. Paste the API user's details**

Fill in **API user email** and **API user password**. **Webhook token** is optional and can be added
later. Click **Connect**.

**4. Avox signs in**

Avox signs in to Shiprocket's API with those details before saving anything. If it works you see
**Shiprocket is connected**. The password is stored encrypted and never shown again.

Shiprocket's sign-in lasts 10 days. Avox signs in again a day before it runs out, so nothing stops.
If Shiprocket refuses the details (a changed password, a deleted API user) you see
[AVX-3686](https://docs.theavoxai.com/error-codes/avx-3686) while connecting, or **Needs reconnecting**
([AVX-3692](https://docs.theavoxai.com/error-codes/avx-3692)) later: click **Reconnect** and paste the new details.

### Turn on tracking updates

Without this, Avox still tracks a shipment whenever someone or an automation asks. With it, every scan
arrives by itself and can start an automation.

1. On Shiprocket's **Overview** in Avox, under **Setup in Shiprocket**, copy Avox's address. It ends in

   `/api/apps/webhooks/parcel/` and a long code. It belongs to your Switchboard only, so keep it
   private. (Shiprocket refuses addresses with its own name in them, so the address says "parcel".)
2. Press **Generate** next to **Webhook token** and copy the token.
3. In Shiprocket open **Settings**, **API**, **Webhooks**, paste the address as the URL, paste the token
   in the **Token** box, switch the webhook on and click **Save**.
4. Back in Avox, save the same token.

Shiprocket sends the token with every update, and Avox refuses any update without the right one. Until
the token is saved in Avox, updates are refused with [AVX-3709](https://docs.theavoxai.com/error-codes/avx-3709). The checklist on
the **Overview** turns green when the first update Avox could check arrives.

## What you see in Avox afterwards

Shiprocket has its own menu under **Apps**: **Overview**, **Shipments** and **Activity**.

- **Overview**: status, the account, who connected it, when it last worked, the last problem with its
  code, the setup checklist, **Test connection**, **Reconnect** and **Disconnect**.
- **Shipments**: Shiprocket's orders, newest first, 20 at a time, searchable by order ID or AWB, with
  the courier, the AWB and whether it is cash on delivery. A second list shows the shipments Avox heard
  about from updates, so the page still has something when Shiprocket can't be read.
- **One shipment**: its status (Ready to ship, Picked up, In transit, Out for delivery, Delivered,
  Delivery failed, Returning to you, Returned to you, Lost or damaged, Cancelled), the tracking
  timeline with each scan's time and place, the expected delivery date, the tracking page, the items and,
  for cash on delivery, the cash to collect. The customer's name, phone and email show only on this page,
  to people who can see apps.
- **Activity**: **Usage** and the **Log**, with **Calls** and **Webhooks** tabs.

## Using Shiprocket in automations

Each of these is an app action an automation step can run:

- **Track a shipment**: give the AWB number or the order ID (one of them). The answer has the status,
  the courier, the last scan, the expected delivery and the tracking page link, ready for a WhatsApp
  reply to "where is my order?". An unknown AWB or order gives [AVX-3741](https://docs.theavoxai.com/error-codes/avx-3741).
- **Cash on delivery status**: whether the order is cash on delivery, the exact amount to collect and
  whether it was delivered. Useful to confirm a COD order on WhatsApp before it ships.
- **Create a return**: only for a delivered order. Avox picks the parcel up from the customer's address
  on the order and sends it to the pickup address the order left from. Items and amounts are copied
  from the order exactly. A step that is tried again never creates a second return.

Tracking updates (picked up, in transit, out for delivery, delivered, failed delivery and returning to
you) are what shipment triggers start on, for example "Out for delivery: tell the customer to keep the
cash ready".

## Money

Amounts are read exactly to the paisa. If Shiprocket ever sends an amount with more decimals than a
rupee has, Avox shows it as unknown rather than round it, and the shipment's page says to check it in
Shiprocket.

## When Shiprocket fails or says no

1. **Avox tries again when that is safe.** Reads are retried up to two more times on a network problem
   or when Shiprocket answers busy (HTTP 429, 502, 503 or 504). Creating a return is never retried on
   its own.
2. **Signing in again.** If Shiprocket stops taking the saved sign-in early, Avox signs in once more and
   tries the call again.
3. **The status changes only when it should.** Refused details mark it **Needs reconnecting**
   ([AVX-3692](https://docs.theavoxai.com/error-codes/avx-3692)). Five failed calls in a row on Shiprocket's side
   ([AVX-3694](https://docs.theavoxai.com/error-codes/avx-3694), [AVX-3695](https://docs.theavoxai.com/error-codes/avx-3695),
   [AVX-3713](https://docs.theavoxai.com/error-codes/avx-3713)) mark it **Having trouble**. A wrong AWB or order ID never counts
   against its health.
4. **Late updates never undo newer ones.** Each update carries the courier's own time. An older scan
   that arrives late changes nothing, and Delivered, Returned to you, Lost or damaged and Cancelled stay
   as they are.
5. **The pages show what Avox saved** when Shiprocket can't be read, with
   [AVX-3717](https://docs.theavoxai.com/error-codes/avx-3717).

## Disconnect Shiprocket

Click **Disconnect** on the **Overview**. Avox signs out of Shiprocket, deletes the details it saved and
keeps the log for your retention period. To be sure they can't be used again, delete Avox's API user
and switch the webhook off in Shiprocket, **Settings**, **API**.

## Common questions

**Shiprocket says the email is already used**

The API user needs its own email address, not the one you sign in to Shiprocket with. Use another
address you control, like `api@yourbrand.in`.

**Updates are refused**

Save the same webhook token in Avox that you typed in Shiprocket ([AVX-3709](https://docs.theavoxai.com/error-codes/avx-3709)).
If you changed it in Shiprocket, generate a new one in Avox and paste it in both places.

**Why can't I create a return?**

Returns are for delivered orders only ([AVX-3742](https://docs.theavoxai.com/error-codes/avx-3742)). For an order still on its
way, cancel it in Shiprocket instead; a parcel the customer refuses comes back to you as RTO by itself.

## Related
