Coupons

Coupons help boost sales on your SellApp storefront — they allow you to attract new customers with exclusive offers and reward existing customers for their previous purchases.

On this page, we'll dive into the different coupon endpoints you can use to manage coupons programmatically. We'll look at how to create, update, and delete coupons.

The coupon model

The coupon model contains all the information about the coupons stores have, including the type, code, and discount amount.

Properties

  • Name
    id
    Type
    integer
    Description

    The unique identifier for the coupon.

  • Name
    code
    Type
    string
    Description

    The coupon code which the customer enters during checkout.

  • Name
    type
    Type
    string
    Description

    The type of coupon. Supported types:

    • PERCENTAGE
    • AMOUNT
  • Name
    discount
    Type
    integer
    Description

    The discount value related to the above type. Examples:

    • PERCENTAGE: 50 (in percentages)
    • AMOUNT: 5 (in dollars)
  • Name
    limit
    Type
    integer
    Description

    The total amount of times this coupon can be applied before it can no longer be used.

  • Name
    store_wide
    Type
    boolean
    Description

    The scope of the coupon; if true it applies to all products in your store. If false, it only applies to certain products.

  • Name
    minimum_amount
    Type
    integer
    Description

    The minimum amount (in dollars) at which the coupon can be applied.

  • Name
    expires_at
    Type
    timestamp
    Description

    The time at which this coupon stops being usable.

  • Name
    created_at
    Type
    timestamp
    Description

    The time at which this coupon was first created.

  • Name
    updated_at
    Type
    timestamp
    Description

    The time at which this coupon was last updated.

  • Name
    store_id
    Type
    integer
    Description

    The ID of the store this coupon belongs to.

  • Name
    deleted_at
    Type
    timestamp
    Description

    The time at which this coupon was deleted.


GET/v1/coupons

List all coupons

This endpoint allows you to retrieve a paginated list of all your coupons. By default, a maximum of fifteen coupons are shown per page.

Optional attributes

  • Name
    limit
    Type
    integer
    Description

    Limit the number of coupons returned

  • Name
    page
    Type
    integer
    Description

    The page number you are attempting to access.

  • Name
    with_trashed
    Type
    boolean
    Description

    Include deleted coupons in the results

  • Name
    only_trashed
    Type
    boolean
    Description

    Limit the results to only deleted coupons

Request

GET
/v1/coupons
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://sell.app/api/v1/coupons');
$request->setRequestMethod('GET');
$request->setHeaders([
  'accept' => 'application/json',
  'Authorization' => 'Bearer {ApiKeyHere}'
]);

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();

Response

{
  "data": [
    {
      "id": 1,
      "code": "BONANZA",
      "type": "PERCENTAGE",
      "discount": "80",
      "limit": null,
      "store_wide": true,
      "minimum_amount": null,
      "expires_at": null,
      "created_at": "2022-12-12T12:12:12.000000Z",
      "updated_at": "2022-12-12T12:12:12.000000Z",
      "store_id": 1,
      "deleted_at": null
    }
  ],
  "links": {
    // ...
  },
  "meta": {
    // ...
  }
}

POST/v1/coupons

Create a coupon

This endpoint allows you to create a new coupon. See the code examples for how to create a new coupon with the SellApp API.

Required attributes

  • Name
    code
    Type
    string
    Description

    The coupon code which the customer enters during checkout.

  • Name
    type
    Type
    string
    Description

    The type of coupon. Supported types:

    • PERCENTAGE
    • AMOUNT
  • Name
    discount
    Type
    integer
    Description

    The discount value related to the above type. Examples:

    • PERCENTAGE: 50 (in percentages)
    • AMOUNT: 5 (in dollars)
  • Name
    store_wide
    Type
    boolean
    Description

    The scope of the coupon; if true it applies to all products in your store. If false, it only applies to certain products.

Optional attributes

  • Name
    limit
    Type
    integer
    Description

    The total amount of times this coupon can be applied before it can no longer be used.

  • Name
    minimum_amount
    Type
    integer
    Description

    The minimum amount (in dollars) at which the coupon can be applied.

  • Name
    expires_at
    Type
    timestamp
    Description

    The time at which this coupon stops being usable.

Request

POST
/v1/coupons
$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{
  "code": "BONANZA",
  "type": "PERCENTAGE",
  "discount": 80,
  "store_wide": true
}');

$request->setRequestUrl('https://sell.app/api/v1/coupons');
$request->setRequestMethod('POST');
$request->setBody($body);

$request->setHeaders([
  'Content-Type' => 'application/json',
  'accept' => 'application/json',
  'Authorization' => 'Bearer {ApiKeyHere}'
]);

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();

Response

{
  "id": 1,
  "code": "BONANZA",
  "type": "PERCENTAGE",
  "discount": "80",
  "limit": null,
  "store_wide": true,
  "minimum_amount": null,
  "expires_at": null,
  "created_at": "2022-12-12T12:12:12.000000Z",
  "updated_at": "2022-12-12T12:12:12.000000Z",
  "store_id": 1,
  "deleted_at": null
}

GET/v1/coupons/:id

Retrieve a coupon

This endpoint allows you to retrieve a specific coupon by providing the unique identifier. Refer to the list at the top of this page to see which properties are included with coupon objects.

Request

GET
/v1/coupons/:id
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://sell.app/api/v1/coupons/1');
$request->setRequestMethod('GET');
$request->setHeaders([
  'accept' => 'application/json',
  'Authorization' => 'Bearer {ApiKeyHere}'
]);

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();

Response

{
  "id": 1,
  "code": "BONANZA",
  "type": "PERCENTAGE",
  "discount": "80",
  "limit": null,
  "store_wide": true,
  "minimum_amount": null,
  "expires_at": null,
  "created_at": "2022-12-12T12:12:12.000000Z",
  "updated_at": "2022-12-12T12:12:12.000000Z",
  "store_id": 1,
  "deleted_at": null
}

PATCH/v1/coupons/:id

Update a coupon

This endpoint allows you to perform an update on a coupon.

Optional attributes

  • Name
    code
    Type
    string
    Description

    The coupon code which the customer enters during checkout.

  • Name
    type
    Type
    string
    Description

    The type of coupon. Supported types:

    • PERCENTAGE
    • AMOUNT
  • Name
    discount
    Type
    integer
    Description

    The discount value related to the above type. Examples:

    • PERCENTAGE: 50 (in percentages)
    • AMOUNT: 5 (in dollars)
  • Name
    store_wide
    Type
    boolean
    Description

    The scope of the coupon; if true it applies to all products in your store. If false, it only applies to certain products.

  • Name
    limit
    Type
    integer
    Description

    The total amount of times this coupon can be applied before it can no longer be used.

  • Name
    minimum_amount
    Type
    integer
    Description

    The minimum amount (in dollars) at which the coupon can be applied.

  • Name
    expires_at
    Type
    timestamp
    Description

    The time at which this coupon stops being usable.

Request

PATCH
/v1/coupons/:id
$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{
  "code": "BAZINGA",
  "type": "PERCENTAGE",
  "discount": 80,
  "store_wide": true
}');

$request->setRequestUrl('https://sell.app/api/v1/coupons/1');
$request->setRequestMethod('PATCH');
$request->setBody($body);

$request->setHeaders([
  'Content-Type' => 'application/json',
  'accept' => 'application/json',
  'Authorization' => 'Bearer {ApiKeyHere}'
]);

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();

Response

{
  "id": 1,
  "code": "BAZINGA",
  "type": "PERCENTAGE",
  "discount": "80",
  "limit": null,
  "store_wide": true,
  "minimum_amount": null,
  "expires_at": null,
  "created_at": "2022-12-12T12:12:12.000000Z",
  "updated_at": "2022-12-12T12:12:12.000000Z",
  "store_id": 1,
  "deleted_at": null
}

DELETE/v1/coupons/:id

Delete a coupon

This endpoint allows you to delete a coupon.

Request

DELETE
/v1/coupons/:id
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://sell.app/api/v1/coupons/1');
$request->setRequestMethod('DELETE');
$request->setHeaders([
  'accept' => 'application/json',
  'Authorization' => 'Bearer {ApiKeyHere}'
]);

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();