Skip to main content
POST
/
api
/
loyalty
/
badges
/
{id}
Update badge (by id)
curl --request POST \
  --url https://admin.snagsolutions.io/api/loyalty/badges/{id} \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: <api-key>' \
  --data '
{
  "name": "Example Badge",
  "description": "Example description",
  "imageUrl": "https://example.com/image.png",
  "hideInUi": false,
  "rewards": [
    {
      "rewardType": "points",
      "loyaltyCurrencyId": "123e4567-e89b-12d3-a456-426614174333",
      "loyaltyCurrencyIds": [
        "123e4567-e89b-12d3-a456-426614174333"
      ],
      "amount": 100,
      "multiplier": 2.5,
      "isRetroactive": false
    }
  ],
  "csvFiles": [
    {
      "src": "<string>",
      "name": "<string>",
      "description": "<string>"
    }
  ]
}
'
import requests

url = "https://admin.snagsolutions.io/api/loyalty/badges/{id}"

payload = {
"name": "Example Badge",
"description": "Example description",
"imageUrl": "https://example.com/image.png",
"hideInUi": False,
"rewards": [
{
"rewardType": "points",
"loyaltyCurrencyId": "123e4567-e89b-12d3-a456-426614174333",
"loyaltyCurrencyIds": ["123e4567-e89b-12d3-a456-426614174333"],
"amount": 100,
"multiplier": 2.5,
"isRetroactive": False
}
],
"csvFiles": [
{
"src": "<string>",
"name": "<string>",
"description": "<string>"
}
]
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Example Badge',
description: 'Example description',
imageUrl: 'https://example.com/image.png',
hideInUi: false,
rewards: [
{
rewardType: 'points',
loyaltyCurrencyId: '123e4567-e89b-12d3-a456-426614174333',
loyaltyCurrencyIds: ['123e4567-e89b-12d3-a456-426614174333'],
amount: 100,
multiplier: 2.5,
isRetroactive: false
}
],
csvFiles: [{src: '<string>', name: '<string>', description: '<string>'}]
})
};

fetch('https://admin.snagsolutions.io/api/loyalty/badges/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://admin.snagsolutions.io/api/loyalty/badges/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Example Badge',
'description' => 'Example description',
'imageUrl' => 'https://example.com/image.png',
'hideInUi' => false,
'rewards' => [
[
'rewardType' => 'points',
'loyaltyCurrencyId' => '123e4567-e89b-12d3-a456-426614174333',
'loyaltyCurrencyIds' => [
'123e4567-e89b-12d3-a456-426614174333'
],
'amount' => 100,
'multiplier' => 2.5,
'isRetroactive' => false
]
],
'csvFiles' => [
[
'src' => '<string>',
'name' => '<string>',
'description' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://admin.snagsolutions.io/api/loyalty/badges/{id}"

payload := strings.NewReader("{\n \"name\": \"Example Badge\",\n \"description\": \"Example description\",\n \"imageUrl\": \"https://example.com/image.png\",\n \"hideInUi\": false,\n \"rewards\": [\n {\n \"rewardType\": \"points\",\n \"loyaltyCurrencyId\": \"123e4567-e89b-12d3-a456-426614174333\",\n \"loyaltyCurrencyIds\": [\n \"123e4567-e89b-12d3-a456-426614174333\"\n ],\n \"amount\": 100,\n \"multiplier\": 2.5,\n \"isRetroactive\": false\n }\n ],\n \"csvFiles\": [\n {\n \"src\": \"<string>\",\n \"name\": \"<string>\",\n \"description\": \"<string>\"\n }\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://admin.snagsolutions.io/api/loyalty/badges/{id}")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Example Badge\",\n \"description\": \"Example description\",\n \"imageUrl\": \"https://example.com/image.png\",\n \"hideInUi\": false,\n \"rewards\": [\n {\n \"rewardType\": \"points\",\n \"loyaltyCurrencyId\": \"123e4567-e89b-12d3-a456-426614174333\",\n \"loyaltyCurrencyIds\": [\n \"123e4567-e89b-12d3-a456-426614174333\"\n ],\n \"amount\": 100,\n \"multiplier\": 2.5,\n \"isRetroactive\": false\n }\n ],\n \"csvFiles\": [\n {\n \"src\": \"<string>\",\n \"name\": \"<string>\",\n \"description\": \"<string>\"\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://admin.snagsolutions.io/api/loyalty/badges/{id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Example Badge\",\n \"description\": \"Example description\",\n \"imageUrl\": \"https://example.com/image.png\",\n \"hideInUi\": false,\n \"rewards\": [\n {\n \"rewardType\": \"points\",\n \"loyaltyCurrencyId\": \"123e4567-e89b-12d3-a456-426614174333\",\n \"loyaltyCurrencyIds\": [\n \"123e4567-e89b-12d3-a456-426614174333\"\n ],\n \"amount\": 100,\n \"multiplier\": 2.5,\n \"isRetroactive\": false\n }\n ],\n \"csvFiles\": [\n {\n \"src\": \"<string>\",\n \"name\": \"<string>\",\n \"description\": \"<string>\"\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "id": "123e4567-e89b-12d3-a456-426614174333",
  "name": "Example Badge",
  "description": "Example description",
  "imageUrl": "https://example.com/image.png",
  "loyaltyConditions": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174333",
      "type": "rule",
      "description": "Example description",
      "amount": 10,
      "repeatCount": 5,
      "requiredCount": 5,
      "loyaltyRuleGroupId": "123e4567-e89b-12d3-a456-426614174333",
      "association": [
        {
          "loyaltyRule": {
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
            "name": "<string>"
          },
          "loyaltyBadge": {
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
            "name": "<string>"
          },
          "loyaltyRuleGroup": {
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
            "name": "<string>"
          },
          "loyaltyCurrency": {
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
            "name": "<string>"
          },
          "loyaltyLeaderboardView": {
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
            "name": "<string>"
          }
        }
      ],
      "loyaltyCurrencyId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "csvUrl": "https://example.com/csv",
      "csvFiles": [
        {
          "id": "123e4567-e89b-12d3-a456-426614174333",
          "url": "https://example.com/file.csv",
          "name": "file.csv",
          "description": "Example description"
        }
      ]
    }
  ],
  "createdAt": "2021-01-01T00:00:00.000Z",
  "updatedAt": "2021-01-01T00:00:00.000Z",
  "hideInUi": false,
  "rewards": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174333",
      "rewardType": "points",
      "loyaltyCurrencyId": "123e4567-e89b-12d3-a456-426614174333",
      "amount": 100,
      "multiplier": 2.5,
      "isRetroactive": false,
      "loyaltyCurrencyIds": [
        "123e4567-e89b-12d3-a456-426614174333"
      ]
    }
  ],
  "loyaltyBadgeUsers": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174333",
      "userId": "123e4567-e89b-12d3-a456-426614174222",
      "websiteId": "123e4567-e89b-12d3-a456-426614174111",
      "organizationId": "123e4567-e89b-12d3-a456-426614174222",
      "status": "active",
      "loyaltyBadgeId": "123e4567-e89b-12d3-a456-426614174333",
      "createdAt": "2021-01-01T00:00:00.000Z",
      "updatedAt": "2021-01-01T00:00:00.000Z",
      "hideInUi": false,
      "progress": "<unknown>",
      "dismissedInUi": false,
      "user": {
        "id": "123e4567-e89b-12d3-a456-426614174222",
        "walletAddress": "0x1234567890abcdef1234567890abcdef12345678"
      },
      "completedAt": "2021-01-01T00:00:00.000Z"
    }
  ],
  "loyaltyRules": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174333",
      "name": "Example Rule"
    }
  ],
  "dataJobs": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174333",
      "status": "pending",
      "createdAt": "2021-01-01T00:00:00.000Z",
      "updatedAt": "2021-01-01T00:00:00.000Z",
      "message": "Data job is pending"
    }
  ]
}
"Forbidden, Could not validate api key"
{
"message": "Not found"
}
{
"success": false,
"message": "Internal server error",
"debugInfo": "Stack trace or additional error details"
}

Authorizations

X-API-KEY
string
header
required

Path Parameters

id
string<uuid>
required

UUID of the badge to update (converted to lowercase)

Example:

"123e4567-e89b-12d3-a456-426614174333"

Body

application/json

Body

Schema for updating an existing badge.

name
string

The name of the badge

Example:

"Example Badge"

description
string

The description of the badge

Example:

"Example description"

imageUrl
string<uri>

The URL of the badge image

Example:

"https://example.com/image.png"

hideInUi
boolean
default:false

Whether to hide this badge in the user interface

Example:

false

rewards
Rewards · object[]

Array of rewards granted when the badge is achieved

csvFiles
object[]

Response

200

Response returned upon successful update of the badge.

id
string<uuid>
required

UUID of the badge (converted to lowercase)

Example:

"123e4567-e89b-12d3-a456-426614174333"

name
string
required

The name of the badge

Example:

"Example Badge"

description
string | null
required

The description of the badge

Example:

"Example description"

imageUrl
string<uri> | null
required

The URL of the badge image

Example:

"https://example.com/image.png"

loyaltyConditions
Loyalty Condition Schema · object[]
required

Array of conditions of the badge

createdAt
string<date-time>
required

The date and time the badge was created

Example:

"2021-01-01T00:00:00.000Z"

updatedAt
string<date-time>
required

The date and time the badge was updated

Example:

"2021-01-01T00:00:00.000Z"

hideInUi
boolean
default:false

Whether to hide this badge in the user interface

Example:

false

rewards
Rewards · object[]

Array of rewards granted when the badge is achieved

loyaltyBadgeUsers
User Badges · object[]

Array of user badges

loyaltyRules
Loyalty Rules · object[]

Array of loyalty rules associated with the badge

dataJobs
Data Jobs · object[]

Array of data jobs associated with the badge