Skip to main content
POST
/
v1
/
validation-rules
/
{validationRuleId}
/
assignments
curl --request POST \
--url https://{cluster}.voucherify.io/v1/validation-rules/{validationRuleId}/assignments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-App-Id: <api-key>' \
--header 'X-App-Token: <api-key>' \
--data '{
"voucher": "v_ssR6vhswwh5odSloN2Vc3O60w7aea018"
}'
{
  "id": "asgm_kPPiNW3smQLRMWiF",
  "rule_id": "val_ZEZmA9oit8aU",
  "related_object_id": "camp_Rv9EuIrkT08YEORb2pUMGSUo",
  "related_object_type": "campaign",
  "created_at": "2022-09-14T07:06:49.557Z",
  "object": "validation_rules_assignment"
}

Authorizations

X-App-Id
string
header
required
X-App-Token
string
header
required
Authorization
string
header
required

The access token received from the authorization server in the OAuth 2.0 flow.

Path Parameters

validationRuleId
string
required

Unique validation rule ID.

Example:

"val_TU4de3EP4dlL"

Query Parameters

force
boolean

If this flag is set to true, the previous assignment with the same data will be deleted and a new one will be added.

Body

application/json

Specify the resource that you would like to assign the validation rule to.

Request body schema for POST v1/validation-rules/{validationRuleId}/assignments.

Defines the related object, e.g. voucher.

Available options:
voucher,
promotion_tier,
campaign,
earning_rule,
distribution,
reward_assignment

Unique related object ID assigned by Voucherify, e.g. v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno for a voucher.

Response

Returns a validation rules assignment object.

Response body for POST v1/validation-rules/{validationRuleId}/assignments. This is an object representing a validation rule assignment.

id
string
required

Validation rule assignment ID.

Example:

"asgm_74F7QZoYbUoljwQO"

rule_id
string
required

Validation rule ID.

Example:

"val_4j7DCRm2IS59"

The resource ID to which the validation rule was assigned.

Example:

"v_JtWunK6jUo7X2qOFj0SyRHq4p9tgENlT"

The type of resource to which the validation rule was assigned.

Available options:
voucher,
campaign,
earning_rule,
reward_assignment,
promotion_tier,
distribution
created_at
string<date-time>
required

Timestamp representing the date and time when the validation rule assignment was created. The value is shown in the ISO 8601 format.

Example:

"2022-02-17T08:18:15.085Z"

object
enum<string>
default:validation_rules_assignment
required

The type of the object represented by the ID.

Available options:
validation_rules_assignment
I