Examples

Common tasks, each in curl, JavaScript, PHP and Python. Put your key in WEBKIO_API_KEY (create one in the console). Every endpoint and field is in the API reference; for events pushed to you, see Webhooks.

Check your key

The account a key belongs to. A quick way to see a key works.

In the API reference: GET /v1/me

curl "https://api.webkio.com/v1/me" \
  -H "Authorization: Bearer $WEBKIO_API_KEY"

List your sites

Every list is cursor-paginated: pass meta.next_cursor as cursor until meta.has_more is false. A site's id is the project_id the other calls take.

In the API reference: GET /v1/projects

curl "https://api.webkio.com/v1/projects?limit=25" \
  -H "Authorization: Bearer $WEBKIO_API_KEY"

Create or update a contact

Matched on email: a new address creates a contact, a known one updates it. Fields you leave out are not changed.

In the API reference: POST /v1/contacts

curl -X POST "https://api.webkio.com/v1/contacts" \
  -H "Authorization: Bearer $WEBKIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"project_id":"SITE_ID","email":"sofia@example.com","name":"Sofia Almeida","tags":["vip"]}'

Add an email subscriber

Optionally to a list (GET /email-lists gives their ids). Someone who unsubscribed is never subscribed again this way.

In the API reference: POST /v1/subscribers

curl -X POST "https://api.webkio.com/v1/subscribers" \
  -H "Authorization: Bearer $WEBKIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"project_id":"SITE_ID","email":"sofia@example.com","name":"Sofia Almeida","list_id":"LIST_ID"}'

Find an order by its number

Orders read exactly as the order webhooks send them.

In the API reference: GET /v1/orders

curl "https://api.webkio.com/v1/orders?number=ORD-260914-0001" \
  -H "Authorization: Bearer $WEBKIO_API_KEY"

Subscribe a URL to an event

The answer carries the signing secret, shown only this once. Leave project_id out to hear about every site.

In the API reference: POST /v1/webhooks

curl -X POST "https://api.webkio.com/v1/webhooks" \
  -H "Authorization: Bearer $WEBKIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"event":"order.paid","target_url":"https://example.com/webkio","project_id":"SITE_ID"}'