Skip to content

Coupons

Endpoints for managing discount coupons and benefits.

List Coupons

GET /api/coupons

Returns a paginated list of coupons with filtering options. Results are limited to a maximum of 100 coupons per request. Works with franchise and company integrations.

Use cases:

  • Query issued coupons
  • Generate usage reports
  • Monitor expiring coupons

Query Parameters

ParameterTypeRequiredDescription
date_startstringYesStart date to filter by creation date (YYYY-MM-DD)
date_endstringYesEnd date to filter by creation date (YYYY-MM-DD)
date_of_use_startstringNoStart date to filter by usage date (YYYY-MM-DD)
date_of_use_endstringNoEnd date to filter by usage date (YYYY-MM-DD)
expiration_date_startstringNoStart date to filter by expiration date (YYYY-MM-DD)
expiration_date_endstringNoEnd date to filter by expiration date (YYYY-MM-DD)
coupon_statusstringNoCoupon status: Used, Not Used, Expired, Expiring
limitintegerYesNumber of coupons per request (max 100)
offsetintegerYesNumber of coupons to skip (min 1)
searchstringNoSearch term for code or client information
order_columnstringYesColumn for sorting (e.g., created_at)
order_typestringYesSort direction: ASC or DESC
modulestringYesModule context: premiado or falae

Request Example

bash
curl -X GET "https://api-b2s.experienciab2s.com/api/coupons?date_start=2024-01-01&date_end=2024-12-31&limit=10&offset=1&order_column=created_at&order_type=DESC&module=falae" \
     -H "Authorization: Bearer YOUR_TOKEN"

Success Response (200)

json
{
  "limit": 10,
  "offset": 1,
  "total": 45,
  "coupons": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "code": "WELCOME2024",
      "status": true,
      "date_of_use": "2024-03-15",
      "expiration_date": "2024-12-31",
      "created_at": "2024-01-15T10:30:00.000Z",
      "bonus": {
        "id": "bonus-uuid",
        "name": "5% Cashback",
        "type": "answer"
      },
      "client": {
        "id": "client-uuid",
        "name": "John Smith",
        "email": "john@example.com",
        "phone": "(11) 99999-9999"
      }
    }
  ]
}

Available Bonus Types

TypeDescription
answerSurvey response
birthdayBirthday
defaultDefault
createCreation
fidelityProgramLoyalty program
prizeDrawPrize draw
marketingMarketing
rouletteRoulette
winning_registration_rouletteRoulette winning registration
infinityInfinity

Get Client Coupons

GET /api/coupons/clients/{company_id}

Returns a list of coupons linked to a specific client using phone, email, or CPF as search criteria. The company_id must be provided in the request path.

Use cases:

  • Check client coupons during service
  • Verify available benefits
  • Validate coupon before redemption

Path Parameters

ParameterTypeRequiredDescription
company_idstringYesCompany ID

Query Parameters

ParameterTypeRequiredDescription
phonestringNo*Phone in international E.164 format (e.g., 551199999999)
emailstringNo*Client email address
cpfstringNo*Client CPF in 000.000.000-00 format

Note: At least one search parameter (phone, email, or cpf) must be provided.

Request Example

bash
curl -X GET "https://api-b2s.experienciab2s.com/api/coupons/clients/103a525c-0ce3-4182-a504-aad595425233?email=client@example.com" \
     -H "Authorization: Bearer YOUR_TOKEN"

Success Response (200)

json
[
  {
    "id": "103a525c-0ce3-4182-a504-aad595425233",
    "status": true,
    "expiration_date": "2024-12-31",
    "date_of_use": "2024-05-10",
    "created_at": "2024-01-01T12:00:00.000Z",
    "code": "ABCDEF123",
    "bonus": {
      "name": "5% Cashback"
    }
  },
  {
    "id": "303a525c-0ce3-4182-a504-aad595425233",
    "status": false,
    "expiration_date": "2024-11-30",
    "date_of_use": null,
    "created_at": "2024-02-15",
    "code": "XYZ789",
    "bonus": {
      "name": "10% Cashback"
    }
  }
]

Response Structure

FieldTypeDescription
idstringUnique coupon ID
codestringCoupon code
statusbooleantrue = used, false = not used
expiration_datestringExpiration date
date_of_usestringUsage date (null if not used)
created_atstringCreation date
bonus.namestringBenefit name

Response Codes

CodeDescription
200Coupons found
400Invalid parameters
401Missing or invalid token
404Client not found

Mark Coupon as Used

PATCH /api/coupons/status/{id}

Updates the coupon status, marking it as used. The system validates if the coupon exists, hasn't been used before, and isn't expired (expiration date must be more than 3 hours from current time).

Automatic validations:

  • If the coupon exists
  • If it hasn't been used before
  • If it's still valid (at least 3 hours before expiration)

Path Parameters

ParameterTypeRequiredDescription
idstringYesUnique ID of the coupon to update

Request Example

bash
curl -X PATCH "https://api-b2s.experienciab2s.com/api/coupons/status/abc123-coupon-id" \
     -H "Authorization: Bearer YOUR_TOKEN"

Success Response (204)

The coupon status was updated successfully. No content is returned in the response.

Error Responses (400)

json
{
  "status": "error",
  "message": "Coupon already used"
}
json
{
  "status": "error",
  "message": "Coupon expired"
}

Response Codes

CodeDescription
204Coupon updated successfully
400Coupon already used or expired
401Missing or invalid token
404Coupon not found

Integration Documentation