amoCRM: label by funnel stage
When a deal reaches the required funnel stage, amoCRM calls the bridge script. It takes the address and contact from the deal, purchases the cheapest label, and records the tracking number in the deal's field and note.
Downloadable files
- amocrm-bridge.php amoCRM bridge: digital funnel webhook, buys a label and writes tracking to the deal
- shippickup.php API client in PHP, single file, no dependencies
What you’ll need
- A server with PHP 7.4+ and HTTPS (standard hosting works), amoCRM with a digital funnel.
- A ShipPickup account and a live API key (
sk_live_…) with the permissions specified in the instructions. The key is created in the dashboard under “API” and stored in your system settings or environment variable.
Step-by-step instructions
- Download
amocrm-bridge.phpandshippickup.phpand upload both files to the same folder on your server. - In the ShipPickup dashboard, create a live API key with
rates:readandlabels:createpermissions. Set the environment variables on the server from the top of the file:SHIPPICKUP_API_KEY,SHIPPICKUP_FROM(sender address JSON),SHIPPICKUP_PARCEL(default parcel JSON),BRIDGE_SECRET(a long random string). - In amoCRM, create a private integration and copy the long-term token into
AMO_TOKEN, and the account domain (e.g.,mycompany.amocrm.ru) intoAMO_DOMAIN. - Add fields to deals: street, city, state, postal code, country (two-letter code), weight in grams (optional), and “Tracking”. Record the field IDs in
AMO_FIELDSas JSON, example at the top of the file. The deal budget is used as the declared value in dollars. - In the funnel settings at the required stage (e.g., “Ready to Ship”), add a “Webhook” trigger on stage entry with the URL
https://your-server/amocrm-bridge.php?secret=BRIDGE_SECRET_VALUE. - For testing, connect a test key: on purchase, the bridge will write a note with the error
test_key_cannot_buyin the deal, indicating the chain works. Then replace the key with a live one.
Important to know
- Repeated calls for the same deal are safe: the idempotency key is built from the deal number, and if the “Tracking” field is filled, the bridge does nothing.
- Purchase errors (insufficient funds, invalid address) are written as notes in the deal and respond with 200 so amoCRM does not resend calls.
Files contain no keys or passwords: all secrets are set by you in environment settings. Do not publish files with your values.