# Set the programme up or change it

`PUT /loyalty` · Rivier · contacts

Set the programme up or change it: its name, what a point is called, how points are earned, levels, when points lapse, the terms, on or off.

- Scope: contacts:admin
- Sdk: contacts.loyalty.set
- Cli: contacts loyalty set

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "off",
        "on"
      ]
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "pointName": {
      "type": "string",
      "minLength": 1,
      "maxLength": 24
    },
    "rules": {
      "type": "object",
      "properties": {
        "spend": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "points": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 1000
                },
                "perMinor": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100000000
                },
                "currency": {
                  "type": "string",
                  "pattern": "^[a-z]{3}$"
                }
              },
              "required": [
                "points",
                "perMinor",
                "currency"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "perOrder": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1000,
          "default": 0
        },
        "perVisit": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1000,
          "default": 0
        },
        "onJoin": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100000,
          "default": 0
        },
        "referral": {
          "type": "object",
          "properties": {
            "referrer": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000
            },
            "friend": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000
            }
          },
          "required": [
            "referrer",
            "friend"
          ],
          "additionalProperties": false,
          "default": {
            "referrer": 0,
            "friend": 0
          }
        },
        "expiryMonths": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 60
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "tiers": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 40
              },
              "fromPoints": {
                "type": "integer",
                "minimum": 1,
                "maximum": 10000000
              },
              "multiplierBp": {
                "type": "integer",
                "minimum": 10000,
                "maximum": 50000,
                "default": 10000
              }
            },
            "required": [
              "name",
              "fromPoints"
            ],
            "additionalProperties": false
          },
          "maxItems": 5,
          "default": []
        },
        "staffLimit": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100000,
          "default": 500
        }
      },
      "additionalProperties": false
    },
    "terms": {
      "type": "string",
      "maxLength": 4000
    }
  },
  "additionalProperties": false
}
```

## Responses

- `200`: Success
- `400`: The request was malformed
- `401`: No valid credential
- `403`: The credential lacks the scope, origin or address
- `429`: Over the key's rate limit; see Retry-After

## Example

```sh
curl -X PUT 'https://api.rivier.ai/loyalty' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "status": "off",
  "name": "string",
  "pointName": "string",
  "rules": {
    "spend": null,
    "perOrder": 0,
    "perVisit": 0,
    "onJoin": 0,
    "referral": {
      "referrer": 0,
      "friend": 0
    },
    "expiryMonths": null,
    "tiers": [],
    "staffLimit": 500
  },
  "terms": "string"
}'
```
