# Spawn Coupon Code Bulk Create Job

Create a coupon-code-bulk-create-job to bulk create a list of coupon codes.

Max number of jobs queued at once we allow for is 100.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m`

**Scopes:**
`coupon-codes:write`

# OpenAPI definition

```json
{
  "openapi": "3.0.2",
  "info": {
    "title": "Coupons API",
    "version": "2023-10-15",
    "description": "The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details.",
    "contact": {
      "name": "Klaviyo Developer Experience Team",
      "email": "developers@klaviyo.com",
      "url": "https://developers.klaviyo.com"
    },
    "termsOfService": "https://www.klaviyo.com/legal/api-terms",
    "license": {
      "name": "License",
      "url": "https://www.klaviyo.com/legal"
    }
  },
  "servers": [
    {
      "url": "https://a.klaviyo.com",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/coupon-code-bulk-create-jobs/": {
      "post": {
        "operationId": "spawn_coupon_code_bulk_create_job",
        "summary": "Spawn Coupon Code Bulk Create Job",
        "description": "Create a coupon-code-bulk-create-job to bulk create a list of coupon codes.\n\nMax number of jobs queued at once we allow for is 100.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m`\n\n**Scopes:**\n`coupon-codes:write`",
        "parameters": [
          {
            "name": "revision",
            "in": "header",
            "description": "API endpoint revision (format: YYYY-MM-DD[.suffix])",
            "required": true,
            "schema": {
              "type": "string",
              "default": "2023-10-15"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CouponCodeCreateJobCreateQuery"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PostCouponCodeCreateJobResponse"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/ClientError"
          },
          "5XX": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "tags": [
          "Coupons"
        ],
        "x-klaviyo-pre-release": "None",
        "x-klaviyo-ratelimit": {
          "burst": "75/s",
          "steady": "700/m"
        },
        "x-klaviyo-scopes": [
          "coupon-codes:write"
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "ErrorSource": {
        "type": "object",
        "properties": {
          "pointer": {
            "description": "A pointer to the source of the error in the request payload.",
            "type": "string",
            "example": "/data",
            "default": "/data"
          }
        },
        "required": [
          "pointer"
        ]
      },
      "APIJobErrorPayload": {
        "type": "object",
        "properties": {
          "id": {
            "description": "Unique identifier for the error.",
            "type": "string",
            "example": "e4eebb08-b055-4a6f-bb13-c8cb69c9eb94",
            "default": "e4eebb08-b055-4a6f-bb13-c8cb69c9eb94"
          },
          "code": {
            "description": "A code for classifying the error type.",
            "type": "string",
            "example": "invalid",
            "default": "invalid"
          },
          "title": {
            "description": "A high-level message about the error.",
            "type": "string",
            "example": "Invalid input",
            "default": "Invalid input"
          },
          "detail": {
            "description": "Specific details about the error.",
            "type": "string",
            "example": "The payload provided in the request is invalid.",
            "default": "The payload provided in the request is invalid."
          },
          "source": {
            "description": "Additional information on the source of the error.",
            "$ref": "#/components/schemas/ErrorSource"
          }
        },
        "required": [
          "id",
          "code",
          "title",
          "detail",
          "source"
        ]
      },
      "CouponCodeCreateQueryResourceObject": {
        "type": "object",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/CouponCodeEnum"
          },
          "attributes": {
            "type": "object",
            "properties": {
              "unique_code": {
                "description": "This is a unique string that will be or is assigned to each customer/profile and is associated with a coupon.",
                "type": "string",
                "example": "ASD325FHK324UJDOI2M3JNES99",
                "default": "ASD325FHK324UJDOI2M3JNES99"
              },
              "expires_at": {
                "description": "The datetime when this coupon code will expire. If not specified or set to null, it will be automatically set to 1 year.",
                "type": "string",
                "format": "date-time",
                "example": "2023-01-01T00:00:00Z",
                "default": "2023-01-01T00:00:00Z"
              }
            },
            "required": [
              "unique_code"
            ]
          },
          "relationships": {
            "type": "object",
            "properties": {
              "coupon": {
                "type": "object",
                "properties": {
                  "data": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "$ref": "#/components/schemas/CouponEnum"
                      },
                      "id": {
                        "type": "string",
                        "example": "10OFF",
                        "default": "10OFF"
                      }
                    },
                    "required": [
                      "type",
                      "id"
                    ]
                  }
                },
                "required": [
                  "data"
                ]
              }
            },
            "required": [
              "coupon"
            ]
          }
        },
        "required": [
          "type",
          "attributes",
          "relationships"
        ]
      },
      "CouponCodeCreateJobCreateQueryResourceObject": {
        "type": "object",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/CouponCodeBulkCreateJobEnum"
          },
          "attributes": {
            "type": "object",
            "properties": {
              "coupon-codes": {
                "description": "Array of coupon codes to create.",
                "type": "object",
                "properties": {
                  "data": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/CouponCodeCreateQueryResourceObject"
                    }
                  }
                },
                "required": [
                  "data"
                ]
              }
            },
            "required": [
              "coupon-codes"
            ]
          }
        },
        "required": [
          "type",
          "attributes"
        ]
      },
      "CouponCodeCreateJobCreateQuery": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/CouponCodeCreateJobCreateQueryResourceObject"
          }
        },
        "required": [
          "data"
        ]
      },
      "PostCouponCodeCreateJobResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "type": {
                "$ref": "#/components/schemas/CouponCodeBulkCreateJobEnum"
              },
              "attributes": {
                "type": "object",
                "properties": {
                  "job_id": {
                    "description": "Unique identifier for retrieving the job. Generated by Klaviyo.",
                    "type": "string"
                  },
                  "status": {
                    "description": "Status of the asynchronous job.",
                    "type": "string",
                    "example": "processing",
                    "default": "processing",
                    "enum": [
                      "cancelled",
                      "complete",
                      "processing",
                      "queued"
                    ]
                  },
                  "created_at": {
                    "description": "The date and time the job was created in ISO 8601 format (YYYY-MM-DDTHH:MM:SS.mmmmmm).",
                    "type": "string",
                    "format": "date-time",
                    "example": "2022-11-08T00:00:00",
                    "default": "2022-11-08T00:00:00"
                  },
                  "total_count": {
                    "description": "The total number of operations to be processed by the job. See `completed_count` for the job's current progress.",
                    "type": "integer",
                    "example": 10,
                    "default": 10
                  },
                  "completed_count": {
                    "description": "The total number of operations that have been completed by the job.",
                    "type": "integer",
                    "example": 9,
                    "default": 9
                  },
                  "failed_count": {
                    "description": "The total number of operations that have failed as part of the job.",
                    "type": "integer",
                    "example": 1,
                    "default": 1
                  },
                  "completed_at": {
                    "description": "Date and time the job was completed in ISO 8601 format (YYYY-MM-DDTHH:MM:SS.mmmmmm).",
                    "type": "string",
                    "format": "date-time",
                    "example": "2022-11-08T00:00:00",
                    "default": "2022-11-08T00:00:00"
                  },
                  "errors": {
                    "description": "Array of errors encountered during the processing of the job.",
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/APIJobErrorPayload"
                    }
                  },
                  "expires_at": {
                    "description": "Date and time the job expires in ISO 8601 format (YYYY-MM-DDTHH:MM:SS.mmmmmm).",
                    "type": "string",
                    "format": "date-time",
                    "example": "2022-11-08T00:00:00",
                    "default": "2022-11-08T00:00:00"
                  }
                },
                "required": [
                  "job_id",
                  "status",
                  "created_at",
                  "total_count"
                ]
              },
              "relationships": {
                "type": "object",
                "properties": {
                  "coupon-codes": {
                    "type": "object",
                    "properties": {
                      "data": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "required": [
                            "type",
                            "id"
                          ],
                          "properties": {
                            "type": {
                              "$ref": "#/components/schemas/CouponCodeEnum"
                            },
                            "id": {
                              "description": "IDs of the created coupon codes.",
                              "type": "string",
                              "example": "10OFF-ASD325FHK324UJDOI2M3JNES99",
                              "default": "10OFF-ASD325FHK324UJDOI2M3JNES99"
                            }
                          }
                        }
                      },
                      "links": {
                        "$ref": "#/components/schemas/RelationshipLinks"
                      }
                    },
                    "required": [
                      "data"
                    ]
                  }
                }
              },
              "links": {
                "$ref": "#/components/schemas/ObjectLinks"
              }
            },
            "required": [
              "type",
              "attributes",
              "links"
            ]
          }
        },
        "required": [
          "data"
        ]
      },
      "RelationshipLinks": {
        "type": "object",
        "properties": {
          "self": {
            "type": "string",
            "format": "uri"
          },
          "related": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "self",
          "related"
        ]
      },
      "ObjectLinks": {
        "type": "object",
        "properties": {
          "self": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "self"
        ]
      },
      "CouponEnum": {
        "type": "string",
        "enum": [
          "coupon"
        ]
      },
      "CouponCodeEnum": {
        "type": "string",
        "enum": [
          "coupon-code"
        ]
      },
      "CouponCodeBulkCreateJobEnum": {
        "type": "string",
        "enum": [
          "coupon-code-bulk-create-job"
        ]
      }
    },
    "responses": {
      "ClientError": {
        "description": "Client Error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "errors": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "id",
                      "code",
                      "title",
                      "detail"
                    ],
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "code": {
                        "type": "string"
                      },
                      "title": {
                        "type": "string"
                      },
                      "detail": {
                        "type": "string"
                      },
                      "source": {
                        "type": "object",
                        "properties": {
                          "pointer": {
                            "type": "string"
                          },
                          "parameter": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              },
              "required": [
                "errors"
              ]
            }
          }
        }
      },
      "ServerError": {
        "description": "Server Error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "errors": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "id",
                      "code",
                      "title",
                      "detail"
                    ],
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "code": {
                        "type": "string"
                      },
                      "title": {
                        "type": "string"
                      },
                      "detail": {
                        "type": "string"
                      },
                      "source": {
                        "type": "object",
                        "properties": {
                          "pointer": {
                            "type": "string"
                          },
                          "parameter": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              },
              "required": [
                "errors"
              ]
            }
          }
        }
      }
    },
    "securitySchemes": {
      "Klaviyo-API-Key": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "Private key authentication for /api/ endpoints is performed by setting the `Authorization` header to `Klaviyo-API-Key your-private-api-key`<br>For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#authentication",
        "x-default": "Klaviyo-API-Key your-private-api-key"
      }
    }
  },
  "tags": [
    {
      "name": "Coupons"
    }
  ],
  "security": [
    {
      "Klaviyo-API-Key": []
    }
  ],
  "x-readme": {
    "explorer-enabled": false,
    "proxy-enabled": true,
    "samples-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 101,
      "1": 45,
      "2": 164,
      "3": 185,
      "4": 236,
      "5": 156,
      "6": 226,
      "7": 0,
      "8": 79,
      "9": 19,
      "10": 207,
      "11": 119
    }
  }
}
```