跳转到内容

cURL

终端窗口
export SPACEPOST_API_KEY="sp_live_YOUR_API_KEY"
终端窗口
curl -X POST https://api.spacepost.dev/emails \
-H "Authorization: Bearer $SPACEPOST_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042-confirmation" \
-d '{
"from": "Acme <hello@acme.com>",
"to": ["user@example.com"],
"subject": "Your order",
"html": "<p>Thanks!</p>",
"tags": [{ "name": "category", "value": "order" }]
}'
200 OK
{ "id": "0192e1c4-7a3b-7c1e-9d2f-3b5a8e6f4c10" }
终端窗口
curl https://api.spacepost.dev/emails/$EMAIL_ID -H "Authorization: Bearer $SPACEPOST_API_KEY"
curl "https://api.spacepost.dev/emails?limit=10" -H "Authorization: Bearer $SPACEPOST_API_KEY"
curl -X POST https://api.spacepost.dev/emails/$EMAIL_ID/cancel -H "Authorization: Bearer $SPACEPOST_API_KEY"
终端窗口
curl -X POST https://api.spacepost.dev/domains \
-H "Authorization: Bearer $SPACEPOST_API_KEY" -H "Content-Type: application/json" \
-d '{ "name": "acme.com" }'
curl -X POST https://api.spacepost.dev/domains/$DOMAIN_ID/verify -H "Authorization: Bearer $SPACEPOST_API_KEY"

使用 -i 查看速率限制标头:

终端窗口
curl -i https://api.spacepost.dev/emails?limit=1 -H "Authorization: Bearer $SPACEPOST_API_KEY"
# ratelimit-limit: 10
# ratelimit-remaining: 9
# ratelimit-reset: 1