173 lines
4.9 KiB
HTTP
173 lines
4.9 KiB
HTTP
###
|
|
# Mailjet API test requests for IntelliJ HTTP Client
|
|
#
|
|
# 1) Fill in variables below (or move them to http-client.private.env.json).
|
|
# 2) Set `mailjet_api_key` and `mailjet_api_secret` in your env file.
|
|
# IntelliJ HTTP Client will inject them into the Authorization header below.
|
|
#
|
|
# Required variables:
|
|
# - mailjet_base_url (example: https://api.mailjet.com/v3/REST)
|
|
# - mailjet_api_key
|
|
# - mailjet_api_secret
|
|
# - mailjet_contact_email
|
|
# - mailjet_list_id
|
|
#
|
|
# @no-cookie-jar
|
|
|
|
### Mailjet health check (authenticated)
|
|
# @no-cookie-jar
|
|
GET {{mailjet_base_url}}/apikey
|
|
Accept: application/json
|
|
Authorization: Basic {{mailjet_api_key}} {{mailjet_api_secret}}
|
|
|
|
|
|
### Find contact by email
|
|
# @no-cookie-jar
|
|
GET {{mailjet_base_url}}/contact?Email={{mailjet_contact_email}}
|
|
Accept: application/json
|
|
Authorization: Basic {{mailjet_api_key}} {{mailjet_api_secret}}
|
|
|
|
> {%
|
|
if (response.body && response.body.Data && response.body.Data.length > 0) {
|
|
client.global.set("contact_id", String(response.body.Data[0].ID));
|
|
}
|
|
%}
|
|
|
|
|
|
### Create contact (run if not found)
|
|
# @no-cookie-jar
|
|
POST {{mailjet_base_url}}/contact
|
|
Accept: application/json
|
|
Content-Type: application/json
|
|
Authorization: Basic {{mailjet_api_key}} {{mailjet_api_secret}}
|
|
|
|
{
|
|
"Email": "{{mailjet_contact_email}}"
|
|
}
|
|
|
|
> {%
|
|
if (response.body && response.body.Data && response.body.Data.length > 0) {
|
|
client.global.set("contact_id", String(response.body.Data[0].ID));
|
|
}
|
|
%}
|
|
|
|
|
|
### Get contact by ID (after find/create)
|
|
# @no-cookie-jar
|
|
GET {{mailjet_base_url}}/contact/{{contact_id}}
|
|
Accept: application/json
|
|
Authorization: Basic {{mailjet_api_key}} {{mailjet_api_secret}}
|
|
|
|
|
|
### Get contact metadata by ID (after find/create)
|
|
# @no-cookie-jar
|
|
GET {{mailjet_base_url}}/contactdata/{{contact_id}}
|
|
Accept: application/json
|
|
Authorization: Basic {{mailjet_api_key}} {{mailjet_api_secret}}
|
|
|
|
### Get newsletter list by ID
|
|
# @no-cookie-jar
|
|
GET {{mailjet_base_url}}/contactslist/{{mailjet_list_id}}
|
|
Accept: application/json
|
|
Authorization: Basic {{mailjet_api_key}} {{mailjet_api_secret}}
|
|
|
|
|
|
### List all available contact lists
|
|
# @no-cookie-jar
|
|
GET {{mailjet_base_url}}/contactslist?Limit=1000
|
|
Accept: application/json
|
|
Authorization: Basic {{mailjet_api_key}} {{mailjet_api_secret}}
|
|
|
|
|
|
### Check list recipient status (before actions)
|
|
# @no-cookie-jar
|
|
GET {{mailjet_base_url}}/listrecipient?ContactsList={{mailjet_list_id}}&Contact={{contact_id}}
|
|
Accept: application/json
|
|
Authorization: Basic {{mailjet_api_key}} {{mailjet_api_secret}}
|
|
|
|
> {%
|
|
if (response.body && response.body.Data && response.body.Data.length > 0) {
|
|
client.global.set("listrecipient_id", String(response.body.Data[0].ID));
|
|
}
|
|
%}
|
|
|
|
|
|
### Subscribe to list (addnoforce)
|
|
# @no-cookie-jar
|
|
POST {{mailjet_base_url}}/contactslist/{{mailjet_list_id}}/managecontact
|
|
Accept: application/json
|
|
Content-Type: application/json
|
|
Authorization: Basic {{mailjet_api_key}} {{mailjet_api_secret}}
|
|
|
|
{
|
|
"Action": "addnoforce",
|
|
"Email": "{{mailjet_contact_email}}"
|
|
}
|
|
|
|
|
|
### Verify list recipient after addnoforce
|
|
# @no-cookie-jar
|
|
GET {{mailjet_base_url}}/listrecipient?ContactsList={{mailjet_list_id}}&Contact={{contact_id}}
|
|
Accept: application/json
|
|
Authorization: Basic {{mailjet_api_key}} {{mailjet_api_secret}}
|
|
|
|
|
|
### Unsubscribe from list (unsub)
|
|
# @no-cookie-jar
|
|
POST {{mailjet_base_url}}/contactslist/{{mailjet_list_id}}/managecontact
|
|
Accept: application/json
|
|
Content-Type: application/json
|
|
Authorization: Basic {{mailjet_api_key}} {{mailjet_api_secret}}
|
|
|
|
{
|
|
"Action": "unsub",
|
|
"Email": "{{mailjet_contact_email}}"
|
|
}
|
|
|
|
|
|
### Verify list recipient after unsub
|
|
# @no-cookie-jar
|
|
GET {{mailjet_base_url}}/listrecipient?ContactsList={{mailjet_list_id}}&Contact={{contact_id}}
|
|
Accept: application/json
|
|
Authorization: Basic {{mailjet_api_key}} {{mailjet_api_secret}}
|
|
|
|
|
|
### Re-subscribe attempt with addnoforce (expected to keep unsubscribed state)
|
|
# @no-cookie-jar
|
|
POST {{mailjet_base_url}}/contactslist/{{mailjet_list_id}}/managecontact
|
|
Accept: application/json
|
|
Content-Type: application/json
|
|
Authorization: Basic {{mailjet_api_key}} {{mailjet_api_secret}}
|
|
|
|
{
|
|
"Action": "addnoforce",
|
|
"Email": "{{mailjet_contact_email}}"
|
|
}
|
|
|
|
|
|
### Verify list recipient after addnoforce re-subscribe attempt
|
|
# @no-cookie-jar
|
|
GET {{mailjet_base_url}}/listrecipient?ContactsList={{mailjet_list_id}}&Contact={{contact_id}}
|
|
Accept: application/json
|
|
Authorization: Basic {{mailjet_api_key}} {{mailjet_api_secret}}
|
|
|
|
|
|
### Re-subscribe with addforce (expected to re-subscribe)
|
|
# @no-cookie-jar
|
|
POST {{mailjet_base_url}}/contactslist/{{mailjet_list_id}}/managecontact
|
|
Accept: application/json
|
|
Content-Type: application/json
|
|
Authorization: Basic {{mailjet_api_key}} {{mailjet_api_secret}}
|
|
|
|
{
|
|
"Action": "addforce",
|
|
"Email": "{{mailjet_contact_email}}"
|
|
}
|
|
|
|
|
|
### Verify list recipient after addforce
|
|
# @no-cookie-jar
|
|
GET {{mailjet_base_url}}/listrecipient?ContactsList={{mailjet_list_id}}&Contact={{contact_id}}
|
|
Accept: application/json
|
|
Authorization: Basic {{mailjet_api_key}} {{mailjet_api_secret}}
|