Apply a media campaign offer code on an invoice
This API helps you to apply a media campaign offer code on an invoice. By doing so, you can provide your guests the option to avail promotional discounts on their invoice when they purchase any services or products from your Customer Mobile Application (CMA) or custom Webstore. For more information on how to configure a media campaign, refer to this Help article.
You must specify appropriate data for the invoice_id parameter.
Before you begin
- You need a valid API key or access token. See Set up API authentication.
Permission: Manage API Keys (on the Administrator security object) — Required to access Zenoti APIs.
Endpoint
POST /v1/invoices/{invoice_id}/campaign_discount/apply
Base URL: https://api.zenoti.com
Request
Headers
| Header | Required | Description |
|---|---|---|
| Authorization | Yes | bearer {{access_token}} |
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| invoice_id | string | Yes | Mandatory Unique 32-character identifier of the guest's invoice. |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
| offer_code | string | Yes | media campaign offer code to be redeemed |
| center_id | string | Yes | Center where the redemptions has to happen. |
| voucher_code | string | No | Voucher code associated with the campaign. Used when the campaign requires voucher validation. |
Response
Success (201 Created)
{
"discount_applied": "true",
"campaign_id": "518D91A3-676C-4E3B-9537-036BA071F023",
"error": {}
}
Response fields
| Field | Type | Description |
|---|---|---|
| discount_applied | string | |
| campaign_id | string | |
| error | object |
Example
curl --request POST \
--url 'https://api.zenoti.com/v1/invoices/{invoice_id}/campaign_discount/apply' \
--header 'Authorization: bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{
"offer_code": "offer_code",
"center_id": "(center_id)",
"voucher_code": "string"
}'
const response = await fetch('https://api.zenoti.com/v1/invoices/{invoice_id}/campaign_discount/apply', {
method: 'POST',
headers: {
'Authorization': 'bearer {{access_token}}',
'Content-Type': 'application/json'
},
body: JSON.stringify({ offer_code: 'offer_code', center_id: '(center_id)', voucher_code: 'string' })
});
const data = await response.json();
import requests
response = requests.post(
'https://api.zenoti.com/v1/invoices/{invoice_id}/campaign_discount/apply',
headers={
'Authorization': 'bearer {{access_token}}',
},
json={'offer_code': 'offer_code', 'center_id': '(center_id)', 'voucher_code': 'string'}
)
data = response.json()
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "bearer {{access_token}}");
var content = new StringContent(
JsonSerializer.Serialize(new { offer_code = "offer_code", center_id = "(center_id)", voucher_code = "string" }),
Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://api.zenoti.com/v1/invoices/{invoice_id}/campaign_discount/apply", content);
var data = await response.Content.ReadAsStringAsync();
require 'net/http'
require 'json'
uri = URI('https://api.zenoti.com/v1/invoices/{invoice_id}/campaign_discount/apply')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'bearer {{access_token}}'
request['Content-Type'] = 'application/json'
request.body = { offer_code: 'offer_code', center_id: '(center_id)', voucher_code: 'string' }.to_json
response = http.request(request)
data = JSON.parse(response.body)
Error codes
| Status | Description |
|---|---|
| 400 | 400 |
| 401 | Unauthorized -- invalid or expired access token |
| 429 | Too many requests -- rate limit exceeded |