Create a Rule Promotion Job
POSThttps://useast.api.elasticpath.com/v2/rule-promotions/:uuid/jobs
Creates an asynchronous job for a specific Rule Promotion. Jobs are used to generate or export promotion codes in bulk.
The following job types are supported:
code_generate
: Generates a batch of unique promotion codes.code_export
: Exports all existing promotion codes as a downloadable CSV file.
Job processing occurs asynchronously. The job request is queued, and its status must be checked separately.
Job Processing Status
Jobs can have the following statuses:
pending
: Job is in the queue, waiting to be processed.processing
: Job is actively being processed.completed
: Job completed successfully.failed
: Job encountered an error and did not complete.cancelling
: Cancellation in progress (for long-running jobs).cancelled
: Job was successfully cancelled.
Please refer to the OpenAPI examples section on this page for sample job creation requests.
Request
Path Parameters
uuid stringrequired
The unique identifier of the rule promotion.
- application/json
Bodyrequired
data object
Responses
- 201
- 400
Promotion job created
- application/json
- Schema
- Example (auto)
Schema
data object
{
"data": {
"id": "string",
"type": "promotion_job",
"rule_promotion_id": "string",
"job_type": "string",
"name": "string",
"parameters": {},
"status": "string",
"error": "string",
"meta": {
"timestamps": {
"created_at": "2024-07-29T15:51:28.071Z",
"updated_at": "2024-07-29T15:51:28.071Z"
}
},
"generate_result": {
"generated": 1000,
"deleted": 50
}
}
}
Bad Request
- application/json
- Schema
- Example (auto)
- TooManyJobsError
Schema
errors object[]
{
"errors": [
{
"status": "400",
"title": "Too many jobs",
"detail": "Only 1 pending or processing job is allowed per promotion."
}
]
}
Error When Attempting to Create a Job While Another Job is Still Processing
{
"errors": [
{
"status": "400",
"title": "Too many jobs",
"detail": "Only 1 pending or processing job is allowed per promotion."
}
]
}
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/rule-promotions/:uuid/jobs");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer <token>");
var content = new StringContent("{\n \"data\": {\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_application\",\n \"code_prefix\": \"string\",\n \"code_length\": 8\n }\n }\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
ResponseClear