> ## Documentation Index
> Fetch the complete documentation index at: https://learn.nexudus.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create CommunityPerk

> Create a new CommunityPerk record.

A **CommunityPerk** represents a perk, discount, or benefit that a location offers to its customers in partnership with other businesses.

Perks can be discounts, free trials, or any other benefit negotiated with a partner business — for example, 50% off a car rental or a free hot drink at a nearby café. They are published on the Members Portal where customers can view and claim them.

Use `Active` to control visibility — when `false`, the perk is only visible on the Admin Panel. Use `ShowInHomePage` to feature a perk on the Members Portal home page after users log in.

Availability can be restricted via `OnlyForContacts` and `OnlyForMembers`. If neither flag is set, the perk is available to all customers. Use `Tariffs` to further restrict access to customers on specific pricing plans.

Which perks are listed in a location is also controlled by the `Access.Data.Perks` **BusinessSetting**, whose value is an `eDataVisibilityCriteria` enum integer. This determines which locations' perks are visible to customers at a given location — for example `ThisLocationOnly` (7) shows only perks belonging to the current location, while `AllLocations` (3) shows perks from all locations in the network.

## Authentication

<Note>
  This endpoint requires OAuth2 authentication. Include a valid bearer token in the `Authorization` header.
  The authenticated user must be a full unrestricted administrator or have the **`CommunityPerk-Create`** role.
</Note>

## Enums

<Accordion title="eDataVisibilityCriteria">
  | Value | Name                 |
  | ----- | -------------------- |
  | 1     | AllChildren          |
  | 2     | AllParents           |
  | 3     | AllLocations         |
  | 4     | HomeLocationOnly     |
  | 5     | HomeLocationChildren |
  | 6     | HomeLocationParents  |
  | 7     | ThisLocationOnly     |
  | 8     | AllParentChildren    |
</Accordion>

## Request Body

### Required Fields

<ParamField body="BusinessId" type="integer" required>
  ID of the location this perk belongs to.
</ParamField>

<ParamField body="Title" type="string" required>
  Name of the perk as displayed on the Members Portal and the Admin Panel.
</ParamField>

<ParamField body="DisplayOrder" type="integer" required>
  Position of this perk in the list relative to other perks. Lower values appear first.
</ParamField>

<ParamField body="ClickCount" type="integer" required>
  Number of times customers have clicked on this perk.
</ParamField>

### Optional Fields

<ParamField body="PerkUrl" type="string">
  URL where customers are redirected when clicking the Claim button. If blank, no Claim button is shown. Must start with https\://.
</ParamField>

<ParamField body="SummaryText" type="string">
  Short description shown under the perk title on the Perks listing page of the Members Portal.
</ParamField>

<ParamField body="FullText" type="string">
  Full description of the perk, displayed when a customer clicks on it from the Perks listing page.
</ParamField>

<ParamField body="NewImageUrl" type="string">
  URL of a new small image to upload for this perk.
</ParamField>

<ParamField body="ClearImageFile" type="boolean">
  Set to true to remove the current small image from this perk.
</ParamField>

<ParamField body="NewLargeImageUrl" type="string">
  URL of a new large image to upload for this perk.
</ParamField>

<ParamField body="ClearLargeImageFile" type="boolean">
  Set to true to remove the current large image from this perk.
</ParamField>

<ParamField body="Active" type="boolean">
  Whether this perk is published and visible to customers on the Members Portal. When false, the perk is only visible on the Admin Panel.
</ParamField>

<ParamField body="GroupName" type="string">
  Group or category this perk belongs to, used to organise perks on the Members Portal.
</ParamField>

<ParamField body="ShowInHomePage" type="boolean">
  Whether to feature this perk on the Members Portal home page after users log in.
</ParamField>

<ParamField body="OnlyForContacts" type="boolean">
  Whether this perk is only available to contacts. Set both OnlyForContacts and OnlyForMembers to false to make the perk available to all customers.
</ParamField>

<ParamField body="OnlyForMembers" type="boolean">
  Whether this perk is only available to members. Set both OnlyForContacts and OnlyForMembers to false to make the perk available to all customers.
</ParamField>

<ParamField body="Tariffs" type="integer[]">
  IDs of the pricing plans (tariffs) whose members can see and claim this perk. Leave empty to make the perk available regardless of pricing plan.
</ParamField>

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST \
    "https://spaces.nexudus.com/api/content/communityperks" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "BusinessId": 0,
      "Title": "",
      "DisplayOrder": 0,
      "ClickCount": 0
  }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://spaces.nexudus.com/api/content/communityperks',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        BusinessId: 0,
        Title: '',
        DisplayOrder: 0,
        ClickCount: 0
      })
    }
  );

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://spaces.nexudus.com/api/content/communityperks',
      headers={
          'Authorization': 'Bearer YOUR_TOKEN',
          'Content-Type': 'application/json'
      },
      json={
          'BusinessId': 0,
          'Title': '',
          'DisplayOrder': 0,
          'ClickCount': 0
      }
  )

  data = response.json()
  ```
</CodeGroup>

## Response

### 200

<ResponseField name="Status" type="integer">
  HTTP status code. `200` on success.
</ResponseField>

<ResponseField name="Message" type="string">
  A human-readable message confirming the creation.
</ResponseField>

<ResponseField name="Value" type="object">
  Contains the `Id` of the newly created record.
</ResponseField>

<ResponseField name="WasSuccessful" type="boolean">
  `true` if the communityperk was created successfully.
</ResponseField>

<ResponseField name="Errors" type="array">
  `null` on success.
</ResponseField>

```json Example Response theme={null}
{
  "Status": 200,
  "Message": "CommunityPerk was successfully created.",
  "Value": {
    "Id": 87654321
  },
  "OpenInDialog": false,
  "OpenInWindow": false,
  "RedirectURL": null,
  "JavaScript": null,
  "UpdatedOn": "2025-01-15T10:30:00Z",
  "UpdatedBy": "admin@example.com",
  "Errors": null,
  "WasSuccessful": true
}
```

### 400

<ResponseField name="Message" type="string">
  A summary of the validation error(s), in the format `PropertyName: error message`.
</ResponseField>

<ResponseField name="Value" type="any">
  `null` on validation failure.
</ResponseField>

<ResponseField name="Errors" type="object[]">
  Array of validation errors.

  <Expandable>
    <ResponseField name="AttemptedValue" type="any">
      The value that was submitted for the field, or `null` if missing.
    </ResponseField>

    <ResponseField name="Message" type="string">
      The validation error message.
    </ResponseField>

    <ResponseField name="PropertyName" type="string">
      The name of the property that failed validation.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="WasSuccessful" type="boolean">
  `false` when the request fails validation.
</ResponseField>

```json Example Response theme={null}
{
  "Message": "Title: is a required field",
  "Value": null,
  "Errors": [
    {
      "AttemptedValue": null,
      "Message": "is a required field",
      "PropertyName": "Title"
    }
  ],
  "WasSuccessful": false
}
```
