Connect your system through the API

Created by Mosaab Musa, Modified on Tue, 1 Dec at 2:34 PM by Mosaab Musa

Summary: create your account, create an app in Settings ← API to get your keys, then request a token, add your pickup address, create the order, pick a carrier and ship. Try all of this in the sandbox first, then move it to production.


Before you start

  • You need a developer who works with REST APIs.
  • There are two environments, each with its own account and keys:
EnvironmentDashboardAPI base URLUse
Sandboxdemo.stage.torod.cohttps://demo.stage.torod.co/en/apiDevelopment and testing; shipments go to a test environment
Production (Live)torod.cohttps://torod.co/en/apiReal shipments


Several stores, or a platform serving many merchants? Start with the same steps as a regular merchant with one store. Once the test passes, contact the Torod team to complete a commercial agreement and get the extra APIs to connect all your stores. See "Move your integration from sandbox to production".


Step 1: Create a merchant account

  1. Sign up at torod.co/ar/sign-up (or on the sandbox dashboard).
  2. Complete your account details. See "Complete your account setup".

Result: you can open the Torod dashboard.


Step 2: Create an app

  1. Open Settings ← API.
  2. In the Apps tab press + Create App.
  3. Fill in the app details and save.

api-apps


Result: the app card shows in Apps.


Step 3: Copy your app keys

  1. On the app card press the key icon.
  2. App Keys shows the Client ID and Client Secret. Press the eye icon to show the secret and copy it.
  3. Store both keys securely in your system. Never share them or send them in a support ticket.
  4. If the secret leaks, regenerate it with the refresh button next to it and update your system.

api-keys


Step 4: Review the docs and the Postman collection

  1. On the same page open the Documentation tab, or open the Torod API collection directly.
  2. Fork the Torod Merchant collection in Postman to your workspace.
  3. Set the base URL in the collection to the sandbox.
  4. Requests in the docs are grouped as: Authorization, Addresses, Orders, Carrier partners, Shipping process, Shipments.


Step 5: Get a token

  1. Send POST /token with client_id and client_secret.
  2. You get bearer_token and its lifetime expires_in.
  3. Send it on every later request in the header: Authorization: Bearer {bearer_token}.
  4. Have your system request a new token when it expires or when you get a 401.


Step 6: Set up shipping (once)

  1. Cities and districts: use Get All Cities and Get All Districts to get the city_id and district_id your addresses and orders need. Store them in your system and refresh them weekly.
  2. Pickup address (warehouse): send Create Address. Keep the warehouse code (warehouse); every shipment uses it.
  3. Wallet: make sure your wallet covers the shipments. See "Top up your wallet".


Step 7: Ship your first order

  1. Create the order: send Create Order with the customer details, item description, order total, payment method, weight and number of boxes. You get order_id. (Creating an order doesn't ship it, unless an automation rule ships it automatically.)
  2. List carriers: send Order Carrier Partners List with order_id and warehouse. You get the available carriers with prices and approximate delivery time. Pick a courier_partner_id.
  3. Ship: send Order Ship Process with order_id, warehouse and courier_partner_id. You get tracking_id and aws_label (the shipping label link).
  4. Print the shipping label: open the shipping label link, print it and stick it on the package.
  5. Check: the shipment shows in Shipments in the dashboard, and its cost is charged to your wallet.

After that: every new order needs Step 7 only.


Step 8: Track the shipment

  • Webhooks (recommended): add a webhook URL to your app and we send every shipment update to your system: order ID, tracking number, status, Arabic and English description, and update time. Verify each call with the Authorization header, which carries your app's client secret. See "Receive shipment updates through webhooks".
  • Or ask when needed: send Shipment Track with tracking_id.


What else can you do through the API?

You want toRequest in the docs
Edit an order before shippingUpdate Order
Cancel an order or shipment and refund the walletShipment / Order Cancel & Refund
Show shipping rates to your customers before the orderCarrier Partners List 2
Turn carriers on or off per warehouseAddress wise carriers Enable/Disable
List your orders or shipmentsOrder List, Shipments List
Add or edit warehousesCreate Address, Update Address, Address List
See the available return typesReturn Type Data
Create a return request for a shipped orderOrder Return Request
Accept or reject a return requestOrder Return Request Accept Reject
Check your wallet balanceGet Wallet Balance
Create a link to top up your walletGet Payment Link


Go live

  1. When your integration and testing are done in the sandbox, open your app in Apps and press the last icon on the app card: Request publishing.
  2. Contact the Torod team from Support with the app name, so the team can test the integration with you.
  3. Once the test passes, the Torod team moves your app to production.
  4. Switch the API base URL in your system to production and use your production keys. After the move, your production keys are in your app on the production environment: Settings ← API ← Apps ← the key icon.

See "Move your integration from sandbox to production".


When to contact us

  • A request returns an error you can't explain from the docs.
  • Send: the app name, environment (sandbox or production), request name, time sent and the error response. Never send your client secret or token.


Related articles

  • Receive shipment updates through webhooks
  • Move your integration from sandbox to production
  • Ways to connect your store

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article