---
title: "Add Member"
method: POST
path: "/v1/loyalties/{campaignId}/members"
tags: ["Loyalties"]
---

# Add Member

`POST /v1/loyalties/{campaignId}/members`

This method assigns a loyalty card to a customer. It selects a [loyalty card](/api-reference/vouchers/get-voucher) suitable for publication, adds a publish entry, and returns the published voucher.  

A voucher is suitable for publication when it's active and hasn't been published yet.  


> 📘 Auto-update campaign
>
> In case you want to ensure the number of publishable codes increases automatically with the number of customers, you should use **auto-update** campaign.

## Request body

- LoyaltiesMembersCreateRequestBody — Create publication
  - `voucher` string — Code of voucher being published.
  - `source_id` string — The merchant's publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. If `source_id` is provided only 1 voucher can be published per request.
  - `customer` Customer, required
    - `id` string — The ID of an existing customer.
    - `source_id` string — A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored.
    - `name` string — Customer's first and last name.
    - `description` string — An arbitrary string that you can attach to a customer object.
    - `email` string — Customer's email address.
    - `phone` string — Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel.
    - `birthday` string, date — `Deprecated`. ~~Customer's birthdate; format YYYY-MM-DD~~.
    - `birthdate` string, date — Customer's birthdate; format YYYY-MM-DD.
    - `address` object, nullable — Customer's address.
      - `city` string — City
      - `state` string — State
      - `line_1` string — First line of address.
      - `line_2` string — Second line of address.
      - `country` string — Country.
      - `postal_code` string — Postal code.
    - `metadata` object — A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments.
  - `metadata` object — The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format.
  - `channel` string — Specify the distribution channel.

## Response `200`

Returns the voucher object that was published to the customer provided in the request payload.

- LoyaltiesMembersCreateResponseBody — This is an object representing a loyalty member.
  - `id` string — Assigned by the Voucherify API, identifies the voucher.
  - `code` string — A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters.
  - `campaign` string — A unique campaign name, identifies the voucher's parent campaign.
  - `campaign_id` string — Assigned by the Voucherify API, identifies the voucher's parent campaign.
  - `category` string — Tag defining the category that this voucher belongs to.
  - `category_id` string — Unique category ID assigned by Voucherify.
  - `type` 'LOYALTY_CARD' — Defines the type of the voucher.
  - `discount` object, nullable
  - `gift` object, nullable
  - `loyalty_card` object — Object representing loyalty card parameters. Child attributes are present only if `type` is `LOYALTY_CARD`. Defaults to `null`.
    - `points` integer — Total number of points added to the loyalty card over its lifespan.
    - `balance` integer — Points available for reward redemption. This is calculated as follows: `balance` = `points` - `expired_points` - `subtracted_points` - `redemption.redeemed_points`.
    - `next_expiration_date` string, date — The next closest date when the next set of points are due to expire.
    - `next_expiration_points` integer — The amount of points that are set to expire next.
    - `pending_points` integer — Shows the number of pending points that will be added to the loyalty card when they are activated automatically or manually.
    - `expired_points` integer — Shows the total number of expired points over the lifetime of the loyalty card.
    - `subtracted_points` integer — Shows the total number of subtracted points over the lifetime of the loyalty card.
  - `start_date` string, date-time — Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is *inactive before* this date.
  - `expiration_date` string, date-time — Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is *inactive after* this date.
  - `validity_timeframe` ValidityTimeframe — Set recurrent time periods when the earning rule is valid. For example, valid for 1 hour every other day.`start_date` **required** when including the `validity_timeframe`.
    - `duration` string — Defines the amount of time an earning rule will be active in ISO 8601 format. For example, an earning rule with a `duration` of `PT1H` will be valid for a duration of one hour.
    - `interval` string — Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, an earning rule with an `interval` of `P2D` will be valid every other day.
  - `validity_day_of_week` integer[] — Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday
  - `validity_hours` ValidityHours — Determines the hours of validity, e.g. to create a happy hours scenario.
    - `daily` object[] — Defines the recurring period(s) when the resource is active. The periods should not overlap.
      - `start_time` string, time — Defines the starting hour of validity in the HH:mm format. The resource is *inactive before* this time.
      - `days_of_week` integer[] — Integer array corresponding to the particular days of the week in which the resource is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday
      - `expiration_time` string, time — Defines the ending hour of validity in the HH:mm format. The resource is *inactive after* this time.
  - `active` boolean, nullable — A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* voucher - `false` indicates an *inactive* voucher
  - `additional_info` string — An optional field to keep any extra textual information about the code such as a code description and details.
  - `metadata` object — The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format.
  - `assets` VoucherAssets — Stores links to images of QR and barcode that correspond to an encrypted voucher code.
    - `qr` object — Stores Quick Response (QR) representation of encrypted code.
      - `id` string — Encrypted voucher code ID.
      - `url` string — URL to QR code *Optional:* Attach query parameters to base URL to customize the image of the encrypted voucher code. - `size`: integer value from `1` to `100` - `format`: string, either `png` (default) or `svg`
    - `barcode` object — Stores barcode representation of encrypted code.
      - `id` string — Encrypted voucher code ID.
      - `url` string — URL to barcode *Optional:* Attach query parameters to base URL to customize the image of the encrypted voucher code. - `size`: integer value from `1` to `100` - `format`: string, either `png` (default) or `svg`
  - `is_referral_code` boolean, nullable — This is always false for loyalty members.
  - `created_at` string, date-time — Timestamp representing the date and time when the voucher was created. The value is shown in the ISO 8601 format.
  - `updated_at` string, date-time — Timestamp representing the date and time when the voucher was last updated in ISO 8601 format.
  - `holder_id` string — Unique identifier of the customer who owns the voucher.
  - `object` string — The type of the object represented by JSON. Default is `voucher`.
  - `publish` object — This object stores a summary of publish events: an events counter and an endpoint which can be called to return details of each event. A publication is required for loyalty cards and referral codes. This object gets updated whenever a voucher has been published. Publication means assigning a code to a particular customer. Typically, a publication is made by distributing your codes to your customers, e.g. through Export to MailChimp or | Required | Optional | | -------- | :------: | | `type`:`LOYALTY_CARD` | `type`:`DISCOUNT_VOUCHER` | | `is_referral_code`:`true` | `type`:`GIFT_VOUCHER` |
    - `object` string — The type of the object represented is by default `list`. To get this list, you need to make a call to the endpoint returned in the `url` attribute.
    - `count` integer — Publication event counter.
    - `url` string — The endpoint where this list of publications can be accessed using a **GET** method. `/v1/vouchers/{voucher_code}/publications`
  - `redemption` object — Stores a summary of redemptions that have been applied to the voucher.
    - `quantity` integer — How many times a voucher can be redeemed. A `null` value means unlimited.
    - `redeemed_quantity` integer — How many times a voucher has already been redeemed.
    - `redeemed_points` integer — Total loyalty points redeemed.
    - `object` string — The type of the object represented is by default `list`. To get this list, you need to make a call to the endpoint returned in the url attribute.
    - `url` string — The endpoint where this list of redemptions can be accessed using a **GET** method. `/v1/vouchers/{voucher_code}/redemptions`

## Other responses

- `400` — Returns an error.
- `404` — Returns an error if the voucher code that was specified in the request payload is not found.

---

[API](https://skmtc.net/voucherifyio/apis/voucherify-api-async-actions.md) · [All operations](https://skmtc.net/voucherifyio/apis/voucherify-api-async-actions/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/voucherifyio/voucherify-api-async-actions/versions/4982266e0494/schema)
