Request and response parameters
Describes the different types of request and response parameters that are used when making calls to the Moosend API.
When making an API request, you can pass different parameters to the API endpoints to determine the response. There are several types of request parameters: header parameters, path parameters, query parameters, and request body parameters.
Not all Moosend API endpoints contain each type of parameter. The API Reference details the specific request and response parameters for each API endpoint.
Header parameters
You must set the correct header parameters in every API request to retrieve the response data in the expected format and data type. The following headers are supported in Moosend API requests:
Request header | Value |
|---|---|
|
|
|
|
For the response header parameter, only the JSON type is supported.
Request header | Value |
|---|---|
|
|
|
|
Query parameters
You can use query parameters for filtering, pagination, and partial responses in the Moosend API. Query parameters are added to the request URL after the query string ?. You can add one or more query parameters separated by &.
The following is an example that shows three query parameters apikey, WithStatistics, and SortMethod.
curl --include \
'https://{hostname}/v3/lists.{Format}?apikey=value1&&WithStatitiscs=value2&SortMethod=value3'
When you have an API request that uses query parameters, you must add the actual value of each parameter after the =. For example:
curl --include \
'https://{hostname}/v3/campaigns.{Format}?apikey=bafe55f4-e53e-4651-8164-c6d6ff05081b'The apikey is an example of a request query parameter that is required in all Moosend API endpoints.
Path parameters
You can use path parameters as identifiers to help you structure your requests. Path parameters appear within the path of the request URL before the query string ? and are usually indicated in curly brackets { }.
The following example shows three path parameters Page, PageSize, and Format:
curl --include \
'https://{hostname}/v3/lists/{Page}/{PageSize}.{Format}?'When you have an API request that uses path parameters, you must replace the path parameter with their actual values in your request. For example:
curl --include \
'https://{hostname}/v3/lists/1/100.json?'
Format is an example of a path parameter that is required in all Moosend API endpoints. There are only two available formats you can use in getting a response: xml and json.
Request body parameters
For POST requests, you must include a request body with parameters. You can find the details of request body parameters for each endpoint, including required fields in the API Reference.
The following is an example of a request body containing the Name, ConfirmationPage, and RedirectAfterUnsubscribePage parameters:
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data-binary "{
\"Name\":\"New List\",
\"ConfirmationPage\":\"www.someUrl.com\",
\"RedirectAfterUnsubscribePage\":\"www.someUrl.com\"
}" \
'https://{hostname}/v3/lists/create.{Format}?apikey='Response body parameters
All responses to API calls include an HTTP status code, a response header, and a response schema with a JSON-formatted body. You can find the details of the response body parameters corresponding to each endpoint in the API Reference.
The following is an example of a JSON response body containing three parameters for Code, Error, and Context:
{
"Code": 0,
"Error": null,
"Context": "e5f6c0a3-1fe6-4d89-951e-eafae0b01368"
}