Create a Promotion Job
POSThttps://useast.api.elasticpath.com/v2/promotions/:promotionID/jobs
Use this endpoint to create an asynchronous job to generate codes and export promotion codes.
Request
Path Parameters
promotionID stringrequired
The unique identifier of a promotion.
Header Parameters
Authorization Bearerrequired
The Bearer token required to get access to the API.
- application/json
Bodyrequired
typestring
Must be set to promotion_job
.
Example:
promotion_job
job_typestring
Specifies the type of task you want to run. For example, code_generate
to generate codes or code_export
to export codes.
Possible values: [code_generate
, code_export
]
namestring
Represents the name of the job. The maximum allowed length is 50.
Possible values: <= 50 characters
parameters object
Responses
- 201
Promotion job created
- application/json
- Schema
- Example (auto)
Schema
data object
{
"data": {
"id": "string",
"type": "promotion_job",
"promotion_id": "string",
"job_type": "string",
"name": "string",
"parameters": {},
"status": "string",
"meta": {
"timestamps": {
"created_at": "2024-07-29T15:51:28.071Z",
"updated_at": "2024-07-29T15:51:28.071Z"
}
}
}
}
Authorization: http
name: bearerAuthtype: httpscheme: bearer
- csharp
- curl
- dart
- go
- http
- java
- javascript
- kotlin
- c
- nodejs
- objective-c
- ocaml
- php
- powershell
- python
- r
- ruby
- rust
- shell
- swift
- HTTPCLIENT
- RESTSHARP
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://useast.api.elasticpath.com/v2/promotions/:promotionID/jobs");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer <token>");
var content = new StringContent("{\n \"type\": \"promotion_job\",\n \"job_type\": \"code_generate\",\n \"name\": \"string\",\n \"parameters\": {\n \"number_of_codes\": 0,\n \"max_uses_per_code\": 0,\n \"consume_unit\": \"per_item\",\n \"code_prefix\": \"string\",\n \"code_length\": 0\n }\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
ResponseClear