Skip to main content

Create a Promotion Job

POST 

https://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.

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
    number_of_codesinteger

    Specifies the number of codes to be generated. It cannot be greater than the maximum number of codes per promotion, which defaults at 1000.

    Possible values: <= 1000

    max_uses_per_codeinteger

    Specifies the maximum number of usages of a code. If set to zero, you cannot use this promotion. If no value is set, it can be used unlimited times.

    consume_unitstring

    Specifies whether the usage limitation is at the item-level or cart-level.

    Possible values: [per_item, per_cart]

    code_prefixstring

    Indicates the prefix to include with the promotion code. For example, when the generated value is aa2b-3c4d and the prefix value is set as summer, the promotion code becomes summer-aa2b-3c4d.

    code_lengthinteger

    Specifies the code length, which ranges from 8 to 16 characters. The default code length is eight characters, and a dash is added after every four characters in the code. For example, aa2b-3c4d.

Responses

Promotion job created

Schema
    data object
    idstring

    A unique ID generated when a job is created.

    typestring

    Always promotion_job.

    Example: promotion_job
    promotion_idstring

    A unique ID of a promotion.

    job_typestring

    The type of job you want to run. For example, code_generate to generate codes or code_export to export codes.

    namestring

    The name of the job. The maximum length allowed is 50 characters.

    parametersobject
    statusstring

    The status of the job. See Overview.

    meta object
    timestamps object
    created_atdate-time

    The creation date of the job.

    updated_atdate-time

    The last updated date of the job.

Authorization: http

name: bearerAuthtype: httpscheme: bearer
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());
Request Collapse all
Base URL
https://useast.api.elasticpath.com
Auth
Parameters
— pathrequired
— headerrequired
Body required
{
  "type": "promotion_job",
  "job_type": "code_generate",
  "name": "string",
  "parameters": {
    "number_of_codes": 0,
    "max_uses_per_code": 0,
    "consume_unit": "per_item",
    "code_prefix": "string",
    "code_length": 0
  }
}
ResponseClear

Click the Send API Request button above and see the response here!