Skip to content

Coupons

SDK Reference · Resource

Coupons

Create, validate, redeem, and inspect discount coupons.

method

list()

List available coupons

Returns coupons visible to the authenticated account. Staff accounts receive administrative fields; customers receive the public coupon view.

Signature

Promiseclient.coupons.list(options: CouponsListOptions = {}): Promise<CouponsListResponse>

Parameters

NameTypeRequirementDescription
codestringOptional—
limitnumberOptionalNumber of results to return per page.
offsetnumberOptionalThe initial index from which to return the results.
orderingstringOptionalWhich field to use when ordering the results.
searchstringOptionalCase-insensitive partial search across Coupon fields: `title` and `content`. Separate multiple terms with spaces or commas; every term must match at least one listed field.
typestringOptional* `free_data` - Free Data * `monetary` - Money * `percentage` - Percentage
acceptLanguagestringOptionalPreferred language for human-readable API errors. Supported languages: en, ru, uk, de, it, fr, es, zh-hans, ja. Regional language tags and quality weights are accepted; unsupported or omitted values use English.

Example

const result = await client.coupons.list();

Returns

PaginatedCouponShortList

The operation completed successfully.

typePaginatedCouponShortList4fields
count
number
Required
—
next
string
Optional
—
previous
string
Optional
—
results
CouponShort[]
Required
—
typeCouponShort14fields
id
string
Optional
—
is_expired
boolean
Required
—
is_redeemed
boolean
Required
—
packages
PackageShort[]
Required
—
typePackageShort5fields
id
string
Optional
—
name
string
Required
Unique display name for this package shown to customers and in the admin. Residential Starter Business Pro
alias
string
Required
Lowercase alphanumeric identifier used internally for package resolution and proxy username routing. Cannot be changed without affecting active connections. residential01 bizpro
is_unlimited_data
boolean
Optional
When enabled, users on this package have no data cap. The proxy will not enforce any bandwidth limit.
targeting_options
TargetingOptions
Required
—
typeTargetingOptions25fields
package
string
Required
—
split_char
string
Required
—
value_char
string
Required
—
continent
string
Required
—
country
string
Required
—
region
string
Required
—
city
string
Required
—
asn
string
Required
—
isp
string
Required
—
username
string
Required
—
pool
string
Required
—
location
string
Required
—
location_format
string
Required
—
session
string
Required
—
session_mode_tag
string
Required
—
session_ttl
string
Required
—
session_ttl_format
number
Required
—
os
string
Required
—
os_combined
boolean
Required
—
os_split_char
string
Required
—
os_linux
string
Required
—
os_windows
string
Required
—
os_ios
string
Required
—
os_macos
string
Required
—
os_android
string
Required
—
created
string
Required
—
value
number
Required
Arbitrary coupon value
code
string
Required
Leaving this field empty will generate a random code.
is_multi_use
boolean
Optional
If true, coupon can be used multiple times.
is_available_to_one_time
boolean
Optional
If true, coupon can not be used for one-time package tiers.
type
CouponTypeEnum
Required
—
enumCouponTypeEnum0fields

* `free_data` - Free Data * `monetary` - Money * `percentage` - Percentage

No fields.

limit
number
Optional
Number of times coupon can be used
valid_until
string
Optional
Leave empty for coupons that never expire
marketer
string
Optional
The marketer who owns this coupon. Required if is_marketer is true.
user
string
Required
The user who created this coupon.

Throws

ApiError

Normalized API, transport, and response processing failure.

  • kind: "validation"The request arguments or business rules are invalid.
  • kind: "authentication"Authentication credentials are missing, expired, or invalid.
  • kind: "permission"The authenticated account cannot perform this operation.
  • kind: "network"The request could not reach ProxyRequest.
  • kind: "unexpected"The response could not be decoded or did not match the SDK contract.
Advanced variants
  • client.coupons.listWithResponse(options): Promise<ApiResponse<CouponsListResponse>>

    Returns response status, headers, ETag and idempotency metadata with the decoded data.

method

create()

Create a coupon

Creates a coupon. This operation is restricted to administrators.

Signature

Promiseclient.coupons.create(options: CouponsCreateOptions): Promise<CouponsCreateResponse>

Parameters

NameTypeRequirementDescription
idempotencyKeystringOptionalStable key for one logical mutation. Successful responses are replayable for 24 hours; reusing a key with a different request fails.
acceptLanguagestringOptionalPreferred language for human-readable API errors. Supported languages: en, ru, uk, de, it, fr, es, zh-hans, ja. Regional language tags and quality weights are accepted; unsupported or omitted values use English.
bodyCouponCreateRequestRequired—

Example

const result = await client.coupons.create({
body: {
"value": -9223372036854776000,
"type": "free_data"
}
});

Returns

Coupon

The resource or action result was created successfully.

typeCoupon16fields
id
string
Optional
—
redeemed_count
number
Required
—
is_expired
boolean
Required
—
is_redeemed
boolean
Required
—
packages
PackageShort[]
Required
—
typePackageShort5fields
id
string
Optional
—
name
string
Required
Unique display name for this package shown to customers and in the admin. Residential Starter Business Pro
alias
string
Required
Lowercase alphanumeric identifier used internally for package resolution and proxy username routing. Cannot be changed without affecting active connections. residential01 bizpro
is_unlimited_data
boolean
Optional
When enabled, users on this package have no data cap. The proxy will not enforce any bandwidth limit.
targeting_options
TargetingOptions
Required
—
typeTargetingOptions25fields
package
string
Required
—
split_char
string
Required
—
value_char
string
Required
—
continent
string
Required
—
country
string
Required
—
region
string
Required
—
city
string
Required
—
asn
string
Required
—
isp
string
Required
—
username
string
Required
—
pool
string
Required
—
location
string
Required
—
location_format
string
Required
—
session
string
Required
—
session_mode_tag
string
Required
—
session_ttl
string
Required
—
session_ttl_format
number
Required
—
os
string
Required
—
os_combined
boolean
Required
—
os_split_char
string
Required
—
os_linux
string
Required
—
os_windows
string
Required
—
os_ios
string
Required
—
os_macos
string
Required
—
os_android
string
Required
—
stats
CouponStats
Required
—
typeCouponStats5fields
total_redeems
number
Required
—
unique_users
number
Required
—
total_revenue
number
Required
—
total_discount_given
number
Required
—
total_data_given
number
Required
—
created
string
Required
—
value
number
Required
Arbitrary coupon value
code
string
Required
Leaving this field empty will generate a random code.
is_multi_use
boolean
Optional
If true, coupon can be used multiple times.
is_available_to_one_time
boolean
Optional
If true, coupon can not be used for one-time package tiers.
type
CouponTypeEnum
Required
—
enumCouponTypeEnum0fields

* `free_data` - Free Data * `monetary` - Money * `percentage` - Percentage

No fields.

limit
number
Optional
Number of times coupon can be used
valid_until
string
Optional
Leave empty for coupons that never expire
marketer
string
Optional
The marketer who owns this coupon. Required if is_marketer is true.
user
string
Required
The user who created this coupon.

Throws

ApiError

Normalized API, transport, and response processing failure.

  • kind: "validation"The request arguments or business rules are invalid.
  • kind: "authentication"Authentication credentials are missing, expired, or invalid.
  • kind: "permission"The authenticated account cannot perform this operation.
  • kind: "conflict"The operation conflicts with the current resource or idempotency state.
  • kind: "network"The request could not reach ProxyRequest.
  • kind: "unexpected"The response could not be decoded or did not match the SDK contract.
Advanced variants
  • client.coupons.createWithResponse(options): Promise<ApiResponse<CouponsCreateResponse>>

    Returns response status, headers, ETag and idempotency metadata with the decoded data.

method

get()

Get a coupon

Returns one coupon visible within the caller's account scope.

Signature

Promiseclient.coupons.get(options: CouponsGetOptions): Promise<CouponsGetResponse>

Parameters

NameTypeRequirementDescription
idstringRequiredA unique value identifying this Coupon.
acceptLanguagestringOptionalPreferred language for human-readable API errors. Supported languages: en, ru, uk, de, it, fr, es, zh-hans, ja. Regional language tags and quality weights are accepted; unsupported or omitted values use English.

Example

const result = await client.coupons.get({
id: "550e8400-e29b-41d4-a716-446655440000"
});

Returns

CouponShort

The operation completed successfully.

typeCouponShort14fields
id
string
Optional
—
is_expired
boolean
Required
—
is_redeemed
boolean
Required
—
packages
PackageShort[]
Required
—
typePackageShort5fields
id
string
Optional
—
name
string
Required
Unique display name for this package shown to customers and in the admin. Residential Starter Business Pro
alias
string
Required
Lowercase alphanumeric identifier used internally for package resolution and proxy username routing. Cannot be changed without affecting active connections. residential01 bizpro
is_unlimited_data
boolean
Optional
When enabled, users on this package have no data cap. The proxy will not enforce any bandwidth limit.
targeting_options
TargetingOptions
Required
—
typeTargetingOptions25fields
package
string
Required
—
split_char
string
Required
—
value_char
string
Required
—
continent
string
Required
—
country
string
Required
—
region
string
Required
—
city
string
Required
—
asn
string
Required
—
isp
string
Required
—
username
string
Required
—
pool
string
Required
—
location
string
Required
—
location_format
string
Required
—
session
string
Required
—
session_mode_tag
string
Required
—
session_ttl
string
Required
—
session_ttl_format
number
Required
—
os
string
Required
—
os_combined
boolean
Required
—
os_split_char
string
Required
—
os_linux
string
Required
—
os_windows
string
Required
—
os_ios
string
Required
—
os_macos
string
Required
—
os_android
string
Required
—
created
string
Required
—
value
number
Required
Arbitrary coupon value
code
string
Required
Leaving this field empty will generate a random code.
is_multi_use
boolean
Optional
If true, coupon can be used multiple times.
is_available_to_one_time
boolean
Optional
If true, coupon can not be used for one-time package tiers.
type
CouponTypeEnum
Required
—
enumCouponTypeEnum0fields

* `free_data` - Free Data * `monetary` - Money * `percentage` - Percentage

No fields.

limit
number
Optional
Number of times coupon can be used
valid_until
string
Optional
Leave empty for coupons that never expire
marketer
string
Optional
The marketer who owns this coupon. Required if is_marketer is true.
user
string
Required
The user who created this coupon.

Throws

ApiError

Normalized API, transport, and response processing failure.

  • kind: "validation"The request arguments or business rules are invalid.
  • kind: "authentication"Authentication credentials are missing, expired, or invalid.
  • kind: "permission"The authenticated account cannot perform this operation.
  • kind: "not_found"The requested resource does not exist.
  • kind: "network"The request could not reach ProxyRequest.
  • kind: "unexpected"The response could not be decoded or did not match the SDK contract.
Advanced variants
  • client.coupons.getWithResponse(options): Promise<ApiResponse<CouponsGetResponse>>

    Returns response status, headers, ETag and idempotency metadata with the decoded data.

method

replace()

Replace a coupon

Replaces the writable fields of a coupon. Staff access is required.

Signature

Promiseclient.coupons.replace(options: CouponsReplaceOptions): Promise<CouponsReplaceResponse>

Parameters

NameTypeRequirementDescription
idstringRequiredA unique value identifying this Coupon.
ifMatchstringOptionalStrong ETag from the latest representation of this resource.
acceptLanguagestringOptionalPreferred language for human-readable API errors. Supported languages: en, ru, uk, de, it, fr, es, zh-hans, ja. Regional language tags and quality weights are accepted; unsupported or omitted values use English.
bodyCouponUpdateRequestRequired—

Example

const result = await client.coupons.replace({
id: "550e8400-e29b-41d4-a716-446655440000",
body: {
"value": -9223372036854776000,
"type": "free_data"
}
});

Returns

Coupon

The operation completed successfully.

typeCoupon16fields
id
string
Optional
—
redeemed_count
number
Required
—
is_expired
boolean
Required
—
is_redeemed
boolean
Required
—
packages
PackageShort[]
Required
—
typePackageShort5fields
id
string
Optional
—
name
string
Required
Unique display name for this package shown to customers and in the admin. Residential Starter Business Pro
alias
string
Required
Lowercase alphanumeric identifier used internally for package resolution and proxy username routing. Cannot be changed without affecting active connections. residential01 bizpro
is_unlimited_data
boolean
Optional
When enabled, users on this package have no data cap. The proxy will not enforce any bandwidth limit.
targeting_options
TargetingOptions
Required
—
typeTargetingOptions25fields
package
string
Required
—
split_char
string
Required
—
value_char
string
Required
—
continent
string
Required
—
country
string
Required
—
region
string
Required
—
city
string
Required
—
asn
string
Required
—
isp
string
Required
—
username
string
Required
—
pool
string
Required
—
location
string
Required
—
location_format
string
Required
—
session
string
Required
—
session_mode_tag
string
Required
—
session_ttl
string
Required
—
session_ttl_format
number
Required
—
os
string
Required
—
os_combined
boolean
Required
—
os_split_char
string
Required
—
os_linux
string
Required
—
os_windows
string
Required
—
os_ios
string
Required
—
os_macos
string
Required
—
os_android
string
Required
—
stats
CouponStats
Required
—
typeCouponStats5fields
total_redeems
number
Required
—
unique_users
number
Required
—
total_revenue
number
Required
—
total_discount_given
number
Required
—
total_data_given
number
Required
—
created
string
Required
—
value
number
Required
Arbitrary coupon value
code
string
Required
Leaving this field empty will generate a random code.
is_multi_use
boolean
Optional
If true, coupon can be used multiple times.
is_available_to_one_time
boolean
Optional
If true, coupon can not be used for one-time package tiers.
type
CouponTypeEnum
Required
—
enumCouponTypeEnum0fields

* `free_data` - Free Data * `monetary` - Money * `percentage` - Percentage

No fields.

limit
number
Optional
Number of times coupon can be used
valid_until
string
Optional
Leave empty for coupons that never expire
marketer
string
Optional
The marketer who owns this coupon. Required if is_marketer is true.
user
string
Required
The user who created this coupon.

Throws

ApiError

Normalized API, transport, and response processing failure.

  • kind: "validation"The request arguments or business rules are invalid.
  • kind: "authentication"Authentication credentials are missing, expired, or invalid.
  • kind: "permission"The authenticated account cannot perform this operation.
  • kind: "not_found"The requested resource does not exist.
  • kind: "precondition"A required resource precondition is no longer satisfied.
  • kind: "network"The request could not reach ProxyRequest.
  • kind: "unexpected"The response could not be decoded or did not match the SDK contract.
Advanced variants
  • client.coupons.replaceWithResponse(options): Promise<ApiResponse<CouponsReplaceResponse>>

    Returns response status, headers, ETag and idempotency metadata with the decoded data.

method

update()

Update a coupon

Updates selected coupon fields. Staff access is required.

Signature

Promiseclient.coupons.update(options: CouponsUpdateOptions): Promise<CouponsUpdateResponse>

Parameters

NameTypeRequirementDescription
idstringRequiredA unique value identifying this Coupon.
ifMatchstringOptionalStrong ETag from the latest representation of this resource.
acceptLanguagestringOptionalPreferred language for human-readable API errors. Supported languages: en, ru, uk, de, it, fr, es, zh-hans, ja. Regional language tags and quality weights are accepted; unsupported or omitted values use English.
bodyPatchedCouponUpdateRequestOptional—

Example

const result = await client.coupons.update({
id: "550e8400-e29b-41d4-a716-446655440000",
body: {}
});

Returns

Coupon

The operation completed successfully.

typeCoupon16fields
id
string
Optional
—
redeemed_count
number
Required
—
is_expired
boolean
Required
—
is_redeemed
boolean
Required
—
packages
PackageShort[]
Required
—
typePackageShort5fields
id
string
Optional
—
name
string
Required
Unique display name for this package shown to customers and in the admin. Residential Starter Business Pro
alias
string
Required
Lowercase alphanumeric identifier used internally for package resolution and proxy username routing. Cannot be changed without affecting active connections. residential01 bizpro
is_unlimited_data
boolean
Optional
When enabled, users on this package have no data cap. The proxy will not enforce any bandwidth limit.
targeting_options
TargetingOptions
Required
—
typeTargetingOptions25fields
package
string
Required
—
split_char
string
Required
—
value_char
string
Required
—
continent
string
Required
—
country
string
Required
—
region
string
Required
—
city
string
Required
—
asn
string
Required
—
isp
string
Required
—
username
string
Required
—
pool
string
Required
—
location
string
Required
—
location_format
string
Required
—
session
string
Required
—
session_mode_tag
string
Required
—
session_ttl
string
Required
—
session_ttl_format
number
Required
—
os
string
Required
—
os_combined
boolean
Required
—
os_split_char
string
Required
—
os_linux
string
Required
—
os_windows
string
Required
—
os_ios
string
Required
—
os_macos
string
Required
—
os_android
string
Required
—
stats
CouponStats
Required
—
typeCouponStats5fields
total_redeems
number
Required
—
unique_users
number
Required
—
total_revenue
number
Required
—
total_discount_given
number
Required
—
total_data_given
number
Required
—
created
string
Required
—
value
number
Required
Arbitrary coupon value
code
string
Required
Leaving this field empty will generate a random code.
is_multi_use
boolean
Optional
If true, coupon can be used multiple times.
is_available_to_one_time
boolean
Optional
If true, coupon can not be used for one-time package tiers.
type
CouponTypeEnum
Required
—
enumCouponTypeEnum0fields

* `free_data` - Free Data * `monetary` - Money * `percentage` - Percentage

No fields.

limit
number
Optional
Number of times coupon can be used
valid_until
string
Optional
Leave empty for coupons that never expire
marketer
string
Optional
The marketer who owns this coupon. Required if is_marketer is true.
user
string
Required
The user who created this coupon.

Throws

ApiError

Normalized API, transport, and response processing failure.

  • kind: "validation"The request arguments or business rules are invalid.
  • kind: "authentication"Authentication credentials are missing, expired, or invalid.
  • kind: "permission"The authenticated account cannot perform this operation.
  • kind: "not_found"The requested resource does not exist.
  • kind: "precondition"A required resource precondition is no longer satisfied.
  • kind: "network"The request could not reach ProxyRequest.
  • kind: "unexpected"The response could not be decoded or did not match the SDK contract.
Advanced variants
  • client.coupons.updateWithResponse(options): Promise<ApiResponse<CouponsUpdateResponse>>

    Returns response status, headers, ETag and idempotency metadata with the decoded data.

method

delete()

Delete a coupon

Deletes a coupon that is no longer needed. Staff access is required.

Signature

Promiseclient.coupons.delete(options: CouponsDeleteOptions): Promise<CouponsDeleteResponse>

Parameters

NameTypeRequirementDescription
idstringRequiredA unique value identifying this Coupon.
idempotencyKeystringOptionalStable key for one logical mutation. Successful responses are replayable for 24 hours; reusing a key with a different request fails.
ifMatchstringOptionalStrong ETag from the latest representation of this resource.
acceptLanguagestringOptionalPreferred language for human-readable API errors. Supported languages: en, ru, uk, de, it, fr, es, zh-hans, ja. Regional language tags and quality weights are accepted; unsupported or omitted values use English.

Example

const result = await client.coupons.delete({
id: "550e8400-e29b-41d4-a716-446655440000"
});

Returns

void

No response body

Throws

ApiError

Normalized API, transport, and response processing failure.

  • kind: "validation"The request arguments or business rules are invalid.
  • kind: "authentication"Authentication credentials are missing, expired, or invalid.
  • kind: "permission"The authenticated account cannot perform this operation.
  • kind: "not_found"The requested resource does not exist.
  • kind: "conflict"The operation conflicts with the current resource or idempotency state.
  • kind: "precondition"A required resource precondition is no longer satisfied.
  • kind: "network"The request could not reach ProxyRequest.
  • kind: "unexpected"The response could not be decoded or did not match the SDK contract.
Advanced variants
  • client.coupons.deleteWithResponse(options): Promise<ApiResponse<CouponsDeleteResponse>>

    Returns response status, headers, ETag and idempotency metadata with the decoded data.

method

listRedeems()

List coupon redemptions

Returns accounts and invoices that redeemed the selected coupon.

Signature

Promiseclient.coupons.listRedeems(options: CouponsListRedeemsOptions): Promise<CouponsListRedeemsResponse>

Parameters

NameTypeRequirementDescription
codestringOptional—
idstringRequiredA unique value identifying this Coupon.
limitnumberOptionalNumber of results to return per page.
offsetnumberOptionalThe initial index from which to return the results.
orderingstringOptionalWhich field to use when ordering the results.
typestringOptional* `free_data` - Free Data * `monetary` - Money * `percentage` - Percentage
acceptLanguagestringOptionalPreferred language for human-readable API errors. Supported languages: en, ru, uk, de, it, fr, es, zh-hans, ja. Regional language tags and quality weights are accepted; unsupported or omitted values use English.

Example

const result = await client.coupons.listRedeems({
id: "550e8400-e29b-41d4-a716-446655440000"
});

Returns

PaginatedCouponRedeemList

The operation completed successfully.

typePaginatedCouponRedeemList4fields
count
number
Required
—
next
string
Optional
—
previous
string
Optional
—
results
CouponRedeem[]
Required
—
typeCouponRedeem7fields
id
string
Optional
—
user
string
Required
—
invoice
string
Optional
—
invoice_amount
number
Required
—
discount_applied
number
Required
—
redeemed_at
string
Optional
—
created
string
Required
—

Throws

ApiError

Normalized API, transport, and response processing failure.

  • kind: "validation"The request arguments or business rules are invalid.
  • kind: "authentication"Authentication credentials are missing, expired, or invalid.
  • kind: "permission"The authenticated account cannot perform this operation.
  • kind: "not_found"The requested resource does not exist.
  • kind: "network"The request could not reach ProxyRequest.
  • kind: "unexpected"The response could not be decoded or did not match the SDK contract.
Advanced variants
  • client.coupons.listRedeemsWithResponse(options): Promise<ApiResponse<CouponsListRedeemsResponse>>

    Returns response status, headers, ETag and idempotency metadata with the decoded data.

method

calculatePrice()

Calculate a discounted price

Validates a coupon against the selected package and data amount, then returns both the original and discounted prices without creating an invoice.

Signature

Promiseclient.coupons.calculatePrice(options: CouponsCalculatePriceOptions): Promise<CouponsCalculatePriceResponse>

Parameters

NameTypeRequirementDescription
acceptLanguagestringOptionalPreferred language for human-readable API errors. Supported languages: en, ru, uk, de, it, fr, es, zh-hans, ja. Regional language tags and quality weights are accepted; unsupported or omitted values use English.
bodyCouponCalculatePriceRequestRequired—

Example

const result = await client.coupons.calculatePrice({
body: {
"coupon_code": "{coupon_code}",
"data": 1073741824
}
});

Returns

CouponPriceResponse

The operation completed successfully.

typeCouponPriceResponse3fields
price_original
number
Required
Original price in the service's smallest currency unit.
price_discounted
number
Required
Price after applying the coupon, in the smallest currency unit.
discount_percentage
number
Required
—

Throws

ApiError

Normalized API, transport, and response processing failure.

  • kind: "validation"The request arguments or business rules are invalid.
  • kind: "authentication"Authentication credentials are missing, expired, or invalid.
  • kind: "permission"The authenticated account cannot perform this operation.
  • kind: "network"The request could not reach ProxyRequest.
  • kind: "unexpected"The response could not be decoded or did not match the SDK contract.
Advanced variants
  • client.coupons.calculatePriceWithResponse(options): Promise<ApiResponse<CouponsCalculatePriceResponse>>

    Returns response status, headers, ETag and idempotency metadata with the decoded data.