---
title: "Batch assign/unassign earning rules"
method: POST
path: "/v2/loyalties/programs/{programId}/earning-rules/batch"
tags: ["Programs"]
---

# Batch assign/unassign earning rules

`POST /v2/loyalties/programs/{programId}/earning-rules/batch`

<Info>

<Badge color="gray">Documentation in progress</Badge>

This documentation is in progress. The parameters, fields, request and response bodies, and other data may be subject to change. If you need more information or you want to share feedback, contact [Voucherify support](https://www.voucherify.io/contact-support) or your Technical Account Manager.

</Info>

Assigns and/or unassigns earning rules to/from a program in a single batch.
Unassign operations are processed before assign operations. When the program is
`ACTIVE`, the batch is validated to leave at least one active earning rule assigned.
In strict mode (default) missing earning rules or missing assignments cause the whole
batch to fail.

## Path parameters

- `id` string, required

## Request body

- ProgramEarningRuleBatchRequest — Batch of earning rule assignment operations. `unassign` operations are processed before `assign` operations. Duplicate ids within a batch are rejected.
  - `assign` ProgramEarningRuleAssignItem[], nullable — Earning rules to assign.
    - `id` string, required — Unique earning rule identifier.
  - `unassign` ProgramEarningRuleUnassignItem[], nullable — Earning rules to unassign.
    - `id` string, required — Unique earning rule identifier.

## Response `200`

Batch processing result.

- ProgramEarningRuleBatchResponse — Result of an earning rule assignment batch. Keys are null when the corresponding operation list was not provided.
  - `assigned` ProgramEarningRuleAssignment[], nullable — Assignments created by the batch, or `null` when no assign operations were requested.
    - `earning_rule_id` string — Unique earning rule identifier.
    - `created_at` string, date-time — Assignment creation timestamp (ISO 8601).
    - `object` 'program_earning_rule' — Object type marker.
  - `unassigned` ProgramEarningRuleAssignment[], nullable — Assignments removed by the batch, or `null` when no unassign operations were requested.
    - `earning_rule_id` string — Unique earning rule identifier.
    - `created_at` string, date-time — Assignment creation timestamp (ISO 8601).
    - `object` 'program_earning_rule' — Object type marker.

## Other responses

- `400` — Validation error - request body or query parameters failed validation, or the operation is not allowed in the current resource state.
- `404` — Resource not found.
- `409` — Conflict - e.g. duplicate resource or invalid state transition.
- `423` — Resource locked - a related resource is in a state that prevents this operation.
- `500` — Internal server error.

---

[API](https://skmtc.net/voucherifyio/apis/voucherify-loyalty-v2-api.md) · [All operations](https://skmtc.net/voucherifyio/apis/voucherify-loyalty-v2-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/voucherifyio/voucherify-loyalty-v2-api/revisions/69be73b5cff0/schema)
