Simulators
Contacts, audiences and segments
Test the code that keeps your mailing list against contacts you manage by id or email. The design_studio scenario starts with a Clients segment and one completed import. Reload the scenario so the ids below start at 1. A segment reads back as an audience under the same id, as Resend’s does:
curl -s -X POST "$RYSTIC_URL/_rystic/scenario" -d '{"name":"design_studio"}'
curl -s "$RYSTIC_URL/audiences/aec34d1d-4683-48c0-85d5-9d20a614c61d" -H 'Authorization: Bearer re_placeholder' | jq -c '{object, id, name}'
# -> {"object":"audience","id":"aec34d1d-4683-48c0-85d5-9d20a614c61d","name":"Clients"}
curl -s "$RYSTIC_URL/contacts/imports" -H 'Authorization: Bearer re_placeholder' | jq -c '.data[] | {status, counts}'
# -> {"status":"completed","counts":{"created":64,"failed":0,"skipped":0,"total":64,"updated":0}}
Add a contact to the list
Create a contact, add it to the Clients segment and read it back through the audience route by its email:
curl -s "$RYSTIC_URL/contacts" -H 'Authorization: Bearer re_placeholder' -H 'Content-Type: application/json' -d '{"email":"nina@harborbakery.example","first_name":"Nina","last_name":"Shah"}'
# -> {"id":"d292820c-4409-49d5-8000-000000000001","object":"contact"}
curl -s -X POST "$RYSTIC_URL/contacts/d292820c-4409-49d5-8000-000000000001/segments/aec34d1d-4683-48c0-85d5-9d20a614c61d" -H 'Authorization: Bearer re_placeholder'
# -> {"audienceId":"aec34d1d-4683-48c0-85d5-9d20a614c61d","id":"d292820c-4409-49d5-8000-000000000001"}
curl -s "$RYSTIC_URL/contacts/d292820c-4409-49d5-8000-000000000001/segments" -H 'Authorization: Bearer re_placeholder' | jq -c '[.data[].name]'
# -> ["Clients"]
curl -s "$RYSTIC_URL/audiences/aec34d1d-4683-48c0-85d5-9d20a614c61d/contacts/nina@harborbakery.example" -H 'Authorization: Bearer re_placeholder' | jq -c '{id, first_name, unsubscribed}'
# -> {"id":"d292820c-4409-49d5-8000-000000000001","first_name":"Nina","unsubscribed":false}
Set topic choices and unsubscribe
Opt the contact in to the studio’s news topic, then unsubscribe it by email:
curl -s -X PATCH "$RYSTIC_URL/contacts/d292820c-4409-49d5-8000-000000000001/topics" -H 'Authorization: Bearer re_placeholder' -H 'Content-Type: application/json' -d '{"topics":[{"id":"c700c0db-4f18-438d-973e-64aac243fcff","subscription":"opt_in"}]}'
# -> {"contact_id":"d292820c-4409-49d5-8000-000000000001","object":"contact_topics","topics":[{"id":"c700c0db-4f18-438d-973e-64aac243fcff","subscription":"opt_in"}]}
curl -s -X PATCH "$RYSTIC_URL/contacts/nina@harborbakery.example" -H 'Authorization: Bearer re_placeholder' -H 'Content-Type: application/json' -d '{"unsubscribed":true}'
# -> {"id":"d292820c-4409-49d5-8000-000000000001","object":"contact"}
curl -s "$RYSTIC_URL/contacts/nina@harborbakery.example" -H 'Authorization: Bearer re_placeholder' | jq -c '{id, unsubscribed}'
# -> {"id":"d292820c-4409-49d5-8000-000000000001","unsubscribed":true}
Differs from Resend: the simulator takes the topics object shown above, where Resend takes the list itself as the body and refuses the object with a 422 error (Limitations).
Last updated on