---
updatedAt: 2026-06-09T18:02:28.000Z
agentTools:
  siteIndex: https://docs.recurly.com/llms.txt
  projectIndex: https://docs.recurly.com/recurly-subscriptions/llms.txt
---

# Create Coupon

Creates a new coupon. Please note: coupons cannot be updated after being created.

**DISCOUNT IN DOLLARS**
When specifying a discount amount as a flat amount, the currency must be specified with the amount in an array. For example:
```
<discount_type>dollars</discount_type>
<discount_in_cents>
  <USD>500</USD>
  <EUR>400</EUR>
  <GBP>300</GBP>
</discount_in_cents>
```
**DISCOUNT IN PERCENTAGE**
Percentage discounts only need to specify the discount percentage. For example:
```
<discount_type>percent</discount_type>
<discount_percent>10</discount_percent>
```
**LIMITING TO SPECIFIC PLANS**
If a coupon applies to all plans, it will also apply to any plans created in the future. To limit a coupon to specific plans, you may specify an array of plan codes. For example:
```
<applies_to_all_plans>false</applies_to_all_plans>
<plan_codes>
  <plan_code>silver</plan_code>
  <plan_code>gold</plan_code>
</plan_codes>
```

# OpenAPI definition

````json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Recurly V2 API",
    "description": "# Getting Started\nWelcome to the reference documentation for Recurly's XML API v2. Here you will find a complete\nreference for all API v2 operations.\n\nIf you're building a new product, or just getting started with Recurly, we recommend\nusing our newer [JSON API v3](/developers/api/latest).\n\nNow let's get started with API v2.\n# Authentication\n##### API Authentication (HTTP Basic)\nRecurly uses HTTP Basic Authentication—your [API key](https://app.recurly.com/go/developer/api_access) is securely encrypted by the SSL channel.\n\nIf you are testing the API calls via the command line with cURL, try:\n\n```\ncurl -H 'Accept: application/xml' \\\n     -H 'Content-Type: application/xml; charset=utf-8' \\\n     -u [API Key]: https://[subdomain].recurly.com/v2/accounts\n```\n\nIn most programming languages, the API key can be specified in the authentication section of request. If your language requires a username and password, enter the API key in the username and set the password to an empty string.\n\nREGENERATING AN API KEY\nYour API key can be regenerated by clicking on the Regenerate button on the [API credentials](https://app.recurly.com/go/developer/api_access) page.\n\n###### Note\n<div class=\"alert alert--danger\" markdown=\"1\">\nOnly one API key may be active on an account at a time. If you choose to regenerate your API key, your services will not work until you’ve updated all references to your API key. There is only one API key per Recurly site. Regenerating the key will regenerate it for all users.\n\nWhen regenerating your API key, you may choose to expire the prior key immediately or after 12 hours. The 12 hour delay allows you to create a new key to replace your existing API key and maintain API access continuity.\n</div>\n   ##### Calculating your own authorization header\nMost programming languages encode the authorization header automatically. With HTTP Basic Authentication, the `Authorization` header is a string containing a Base-64 encoded username and password. In the case of Recurly’s API, you need only specify the username as your API key. If your library requires a password, set it to an empty string.\n\n```\n\"Authorization\": \"Basic \" + base64_encode(API Key)\n```\n##### Additional headers\nACCEPT HEADER\nRecurly API v2 returns results as XML. Your requests should always include the header requesting the results as XML:\n\n```\nAccept: application/xml\n```\n\nCONTENT-TYPE HEADER\nWhen sending data to Recurly in a POST or PUT request, your request must specify the content type of your request:\n\n```\nContent-Type: application/xml; charset=utf-8\n```\n\nIf your XML request is invalid, the API will respond with a status code 400 Bad Request. This commonly occurs when ampersands are not correctly encoded in the text of your request. Please inspect the body of the response for more details regarding the error.\n   # HTTP Status Codes\n**SUCCESSFUL STATUS CODES (2XX)**\n\n`200 OK`\nThe request was successful.\n`201 Created`\nThe resource was successfully created. Confirms a success when creating a new account, credit, subscription, etc.\n`204 No Content`\nThe request was successful and there is no response body.\n\n**CLIENT ERROR STATUS CODES (4XX)**\n\n`400 Bad Request`\nThe request was invalid or could not be understood by the server. Resubmitting the request will likely result in the same error.\n`401 Unauthorized`\nYour API key is missing or invalid.\n`402 Payment Required`\nYour Recurly account is in production mode but is not in good standing. Please pay any outstanding invoices.\n`403 Forbidden`\nThe login is attempting to perform an action it does not have privileges to access. Verify your login credentials are for the appropriate account.\n`404 Not Found`\nThe resource was not found with the given identifier. The response body will explain which resource was not found.\n`405 Method Not Allowed`\nThe requested method is not valid at the given URL.\n`406 Not Acceptable`\nThe request's Accept header is not set to application/xml.\n`412 Precondition Failed`\nThe request was unsuccessful because a condition was not met. For example, this message may be returned if you attempt to cancel a subscription for an account that has no subscription.\n`422 Unprocessable Entity`\nCould not process a POST or PUT request because the request is invalid. See the response body for more details.\n`429 Too many Requests`\nYou have made too many API requests in the last hour. Future API requests will be ignored until the beginning of the next hour.\n\n**SERVER ERROR STATUS CODES (5XX)**\n\n`500 Internal Server Error`\nThe server encountered an error while processing your request and failed.\n`502 Gateway Error`\nThe load balancer or web server has trouble connecting to the Recurly app. Please try the request again.\n`503 Service Unavailable`\nThe service is temporarily unavailable. Please try the request again.\n\n**FUTURE COMPATIBILITY**\n\nFor future compatibility, please interpret the following status code ranges:\n\n**200–299** as success,\n**400–499** as client request errors,\n**500–599** as server errors\n\n##### 404 Not found responses\nWhen a lookup, update, or delete request is requested on an object that does not exist, the server returns `404 Not Found`:\n\n```\nStatus: 404 Not Found\nContent-Type: application/xml; charset=utf-8\n```\n\n```\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<error>\n  <symbol>not_found</symbol>\n  <description>The record could not be located.</description>\n</error>\n```\n   # Pagination\n##### Number of Records\nEndpoints that return a list of resources will include a header indicating the total number of records available. This is specified with the `X-Records` header. E.g., for an endpoint with 14 records:\n\n```\nX-Records: 14\n```\n##### Next\nThe amount of records returns within a single API request defaults to 50. It may be changed to a maximum of 200 using a `per_page` query parameter, e.g. to return 200 accounts at a time:\n\n```\nhttps://your-subdomain.recurly.com/v2/accounts?per_page=200\n```\n\nWhen there are more records remaining than fit in the current response, the `Link` header is specified with the URI to the next page of results.\n\n```\nStatus: 200 OK\nX-Records: 204\nLink: <https://your-subdomain.recurly.com/v2/accounts?cursor=1304958672>; rel=\"next\"\nETag: \"a4b0568a2278bc591ceb64b31547eb78\"\n```\n\nCURSORS\nThe cursor parameter is a time-based pointer indicating where to resume the results. By using a cursor instead of page numbers, the API avoids returning duplicate records in the case where additional resources are added between pagination requests.\n##### Previous Pages\nAfter paginating beyond the first page of results, the Link header will include a link to return to the first page of results (`rel=\"start\"`) and the previous page (`rel=\"prev\"`):\n\n```\nStatus: 200 OK\nX-Records: 204\nLink: <https://your-subdomain.recurly.com/v2/transactions>; rel=\"start\",\n<https://your-subdomain.recurly.com/v2/transactions?cursor=-1318344434>; rel=\"prev\"\n<https://your-subdomain.recurly.com/v2/transactions?cursor=1318388868>; rel=\"next\"\nETag: \"c7431fcfc386fd59ee6c3c2e9ac2a30c\"\n```\n   # Rate Limits\nIn order to provide a fast response time to all our customers, we may rate limit excessive requests. By default, new Recurly sites have the following API rate limits:\n\n* Sandbox sites: 400 requests/min. All requests count towards the rate limit.\n* Production sites: 1,000 requests/min. Only GET requests count towards the rate limit.\n\nOnce your site moves into production mode, Recurly will only rate limit GET requests. New subscriptions, account modifications, and other requests using POST, PUT, or DELETE methods will not count against your rate limit.\n\nThe rate limit is calculated over a sliding 5 minute window. This means a production site could make 4,000 requests within one minute and not hit the rate limit so long as the site made less than 1,000 requests during the prior 4 minutes.\n\nIf an API request exceeds the rate limit, the API returns a 429 status code indicating `Too Many Requests`. If your business needs a higher limit, please contact support.\n##### HTTP Headers\nEvery authenticated API request returns headers with your current rate limit information. Your requests’ rate limit headers may look like:\n\n```\nX-RateLimit-Limit: 5000\nX-RateLimit-Remaining: 4999\nX-RateLimit-Reset: 1414622019\n```\n\nThe `X-RateLimit-Limit` is your total request limit during the 5 minute window (e.g. requests/min * 5 min). The `X-RateLimit-Remaining` indicates the number of requests remaining until your requests will be denied. Finally, the `X-RateLimit-Reset` header contains a timestamp for when the current window will completely reset assuming no further API requests are made.\n   # API Validation Errors\nf the requested create, update, or delete cannot be performed due to validation errors, the server returns a `422 Unprocessable Entity` response with an array of the validation errors:\n\n```\nStatus: 422 Unprocessable Entity\nContent-Type: application/xml; charset=utf-8\n```\n\n```\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>\n  <error field=\"model_name.field_name\" symbol=\"not_a_number\" lang=\"en-US\">is not a number</error>\n</errors>\n```\n    ",
    "version": "1.0"
  },
  "tags": [
    {
      "name": "coupons",
      "x-displayName": "Coupons"
    }
  ],
  "security": [
    {
      "api_key": []
    }
  ],
  "paths": {
    "/coupons": {
      "post": {
        "summary": "Create Coupon",
        "description": "Creates a new coupon. Please note: coupons cannot be updated after being created.\n\n**DISCOUNT IN DOLLARS**\nWhen specifying a discount amount as a flat amount, the currency must be specified with the amount in an array. For example:\n```\n<discount_type>dollars</discount_type>\n<discount_in_cents>\n  <USD>500</USD>\n  <EUR>400</EUR>\n  <GBP>300</GBP>\n</discount_in_cents>\n```\n**DISCOUNT IN PERCENTAGE**\nPercentage discounts only need to specify the discount percentage. For example:\n```\n<discount_type>percent</discount_type>\n<discount_percent>10</discount_percent>\n```\n**LIMITING TO SPECIFIC PLANS**\nIf a coupon applies to all plans, it will also apply to any plans created in the future. To limit a coupon to specific plans, you may specify an array of plan codes. For example:\n```\n<applies_to_all_plans>false</applies_to_all_plans>\n<plan_codes>\n  <plan_code>silver</plan_code>\n  <plan_code>gold</plan_code>\n</plan_codes>\n```",
        "tags": [
          "coupons"
        ],
        "operationId": "createCoupon",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/xml": {
              "schema": {
                "type": "object",
                "properties": {
                  "coupon_code": {
                    "type": "string",
                    "default": "",
                    "description": "Unique code to identify and redeem the coupon. This code may only contain the following characters: [a-z A-Z 0-9 @ - _ .]. Max of 50 characters"
                  },
                  "name": {
                    "type": "string",
                    "default": "",
                    "description": "Coupon name"
                  },
                  "hosted_description": {
                    "type": "string",
                    "default": "",
                    "description": "Description of the coupon on the hosted payment pages"
                  },
                  "invoice_description": {
                    "type": "string",
                    "default": "",
                    "description": "Description of the coupon on the invoice"
                  },
                  "redeem_by_date": {
                    "type": "string",
                    "format": "date",
                    "default": "",
                    "description": "Last date to redeem the coupon, defaults to no date"
                  },
                  "single_use": {
                    "type": "boolean",
                    "default": "",
                    "description": "If true, the coupon applies to the first invoice only"
                  },
                  "applies_for_months": {
                    "type": "integer",
                    "default": "",
                    "description": "Number of months after redemption that the coupon is valid, defaults to no date"
                  },
                  "max_redemptions": {
                    "type": "string",
                    "default": "",
                    "description": "Maximum number of accounts that may use the coupon before it can no longer be redeemed"
                  },
                  "applies_to_all_plans": {
                    "type": "boolean",
                    "default": "",
                    "description": "The coupon is valid for all plans if true, defaults to true"
                  },
                  "discount_type": {
                    "type": "string",
                    "default": "",
                    "description": "\"percent\" or \"dollars\""
                  },
                  "discount_percent": {
                    "type": "integer",
                    "default": "",
                    "description": "Discount percentage if discount_type is \"percent\""
                  },
                  "discount_in_cents": {
                    "type": "integer",
                    "default": "",
                    "description": "Mapping of discount amounts by currency if discount_type is \"dollars\". Max 10000000."
                  },
                  "plan_codes": {
                    "type": "string",
                    "default": "",
                    "description": "Array of plan_codes the coupon applies to, if applies_to_all_plans is false"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/xml": {
                "example": "Status: 201 Created\nContent-Type: application/xml; charset=utf-8\nLocation: https://your-subdomain.recurly.com/v2/coupons/special\n\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<coupon href=\"https://your-subdomain.recurly.com/v2/coupons/special\">\n  <redemptions href=\"https://your-subdomain.recurly.com/v2/coupons/special/redemptions\"/>\n  <coupon_code>special</coupon_code>\n  <name>Special 10% off</name>\n  <state>redeemable</state>\n  <discount_type>percent</discount_type>\n  <discount_percent type=\"integer\">10</discount_percent>\n  <redeem_by_date type=\"datetime\">2016-07-04T07:00:00Z</redeem_by_date>\n  <single_use type=\"boolean\">true</single_use>\n  <applies_for_months nil=\"nil\"></applies_for_months>\n  <max_redemptions type=\"integer\">10</max_redemptions>\n  <applies_to_all_plans type=\"boolean\">false</applies_to_all_plans>\n  <created_at type=\"datetime\">2015-04-10T07:00:00Z</created_at>\n  <plan_codes type=\"array\">\n    <plan_code>gold</plan_code>\n    <plan_code>platinum</plan_code>\n  </plan_codes>\n  <a name=\"redeem\" href=\"https://your-subdomain.recurly.com/v2/coupons/special/redeem\" method=\"post\"/>\n</coupon>"
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "PHP",
            "source": "try {\n  $coupon = new Recurly_Coupon();\n  $coupon->coupon_code = 'special';\n  $coupon->redeem_by_date = '2016-07-04';\n  $coupon->single_use = true;\n\n  // $2 off...\n  $coupon->name = 'Special $2 off coupon';\n  $coupon->discount_type = 'dollars';\n  $coupon->discount_in_cents->addCurrency('USD',200); // $2.00 discount\n\n  // ...or 10% off.\n  $coupon->name = 'Special 10% off';\n  $coupon->discount_type = 'percent';\n  $coupon->discount_percent = 10;\n\n  // Limit to gold and platinum plans only.\n  $coupon->applies_to_all_plans = false;\n  $coupon->plan_codes = array('gold', 'platinum');\n\n  $coupon->create();\n\n  print \"Coupon: $coupon\";\n} catch (Recurly_ValidationError $e) {\n  print \"Invalid data: $e\";\n}"
          },
          {
            "lang": "Ruby",
            "source": "coupon = Recurly::Coupon.new(\n  :coupon_code    => 'special',\n  :redeem_by_date => Date.new(2014, 1, 1),\n  :single_use     => true\n)\n\n# $2 off...\ncoupon.name = 'Special $2 off coupon'\ncoupon.discount_type = 'dollars'\ncoupon.discount_in_cents = 2_00\n\n# ...or 10% off.\ncoupon.name = 'Special 10% off'\ncoupon.discount_type = 'percent'\ncoupon.discount_percent = 10\n\n# Limit to gold and platinum plans only.\ncoupon.applies_to_all_plans = false\ncoupon.plan_codes = %w(gold platinum)\n\ncoupon.save"
          },
          {
            "lang": "Python",
            "source": "coupon = Coupon(\n  coupon_code='special',\n  redeem_by_date=datetime.date(2014, 1, 1),\n  single_use=True\n)\n\n# $2 off...\ncoupon.name = 'Special $2 off coupon'\ncoupon.discount_type = 'dollars'\ncoupon.discount_in_cents = Money(200)\n\n# ...or 10% off.\ncoupon.name = 'Special 10% off'\ncoupon.discount_type = 'percent'\ncoupon.discount_percent = 10\n\n# Limit to gold and platinum plans only.\ncoupon.applies_to_all_plans = False\ncoupon.plan_codes = ['gold', 'platinum']\n\ncoupon.save()"
          },
          {
            "lang": "Dotnet",
            "source": "var coupon = new Coupon();\ncoupon.CouponCode = \"special\";\ncoupon.RedeemByDate = new DateTime(2017, 1, 1);\ncoupon.SingleUse = true;\n\n// $2 off...\ncoupon.Name = \"Special $2 off coupon\";\ncoupon.DiscountType = Coupon.CouponDiscountType.Dollars\ncoupon.DiscountInCents = new Dictionary<string, int>;\ncoupon.DiscountInCents[\"USD\"] = 200;\n\n// ...or 10% off\ncoupon.Name = \"Special 10% off coupon\";\ncoupon.DiscountType = Coupon.CouponDiscountType.Percent;\ncoupon.DiscountPercent = 10;\n\n// Limit to gold and platinum plans only.\ncoupon.AppliesToAllPlans = false;\ncoupon.Plans.Add(\"gold\");\ncoupon.Plans.Add(\"silver\");\n\n// Other properties\ncoupon.RedeemByDate = new DateTime(2014, 1, 1);\ncoupon.SingleUse = true;\n\ncoupon.Create();"
          },
          {
            "lang": "xml",
            "source": "//  Request for specific plans:\n\nAccept: application/xml\nContent-Type: application/xml; charset=utf-8\n<coupon>\n  <coupon_code>special</coupon_code>\n  <name>Special $2 off coupon</name>\n  <discount_type>dollars</discount_type>\n  <redeem_by_date>2014-01-01</redeem_by_date>\n  <single_use>true</single_use>\n  <max_redemptions>10</max_redemptions>\n  <applies_to_all_plans>true</applies_to_all_plans>\n  <discount_in_cents>\n    <USD>200</USD>\n  </discount_in_cents>\n</coupon>\n\n// Request for $2 coupon:\n\nAccept: application/xml\nContent-Type: application/xml; charset=utf-8\n<coupon>\n  <coupon_code>special</coupon_code>\n  <name>Special 10% off</name>\n  <discount_type>percent</discount_type>\n  <discount_percent>10</discount_percent>\n  <redeem_by_date>2014-01-01</redeem_by_date>\n  <single_use>true</single_use>\n  <max_redemptions>10</max_redemptions>\n  <applies_to_all_plans>false</applies_to_all_plans>\n  <plan_codes>\n    <plan_code>gold</plan_code>\n    <plan_code>platinum</plan_code>\n  </plan_codes>\n</coupon>"
          }
        ]
      }
    }
  },
  "servers": [
    {
      "url": "https://{subdomain}.recurly.com/v2",
      "variables": {
        "subdomain": {
          "description": "Subdomain of your Recurly site.",
          "default": "my-super-successful-company"
        }
      }
    }
  ],
  "components": {
    "securitySchemes": {
      "api_key": {
        "type": "http",
        "description": "Enter the API key as the username and set the password to an empty string. You can locate and manage your API keys from the [API Credentials](https://app.recurly.com/go/developer/api_keys) page.",
        "scheme": "basic"
      }
    }
  }
}
````

# Sibling pages

* [List Active Coupons](https://docs.recurly.com/recurly-subscriptions/reference/listactivecoupons.md)
* [Lookup a Coupon](https://docs.recurly.com/recurly-subscriptions/reference/lookupacoupon.md)
* [Deactivate Coupon](https://docs.recurly.com/recurly-subscriptions/reference/deactivatecoupon.md)