How to hit the Segment API

Segment's HTTP Tracking API at https://api.segment.io/v1 takes the same calls as its libraries: identify, track, page, group.

Authentication

Use Basic auth with the source's write key as the username and an empty password — curl's -u key:, PostTaco's Auth tab. In the examples it's written {{SEGMENT_WRITE_KEY}}.

Full reference: https://segment.com/docs/connections/sources/catalog/libraries/server/http-api/

Track an event

curl -X POST https://api.segment.io/v1/track \
  -u {{SEGMENT_WRITE_KEY}}: \
  -H "Content-Type: application/json" \
  -d '{"userId": "user-123", "event": "Order Completed", "properties": {"revenue": 39.95}}'
Run in PostTaco

Identify a user

curl -X POST https://api.segment.io/v1/identify \
  -u {{SEGMENT_WRITE_KEY}}: \
  -H "Content-Type: application/json" \
  -d '{"userId": "user-123", "traits": {"email": "[email protected]", "plan": "pro"}}'
Run in PostTaco