VipPerkCreateRequest vip.perk-create-request@1
Generated at from
openvibe-contracts v0.53.0 and
openvibe-sdk v0.11.0.
- Version
- 1.0.0
- Owner
- vip
- Visibility
- first-party
- Status
- active
- Compatibility
- backward
- Schema
https://openvibe.network/contracts/vip/perk-create-request.v1.json
vip.perk-create-request@1: the body of vip.perk.create on OpenVibe.VIP. POST /api/v1/perks: { creator?, key?, name, description?, kind?, bindings? } defines a perk for a creator (a service names the creator; a person defines their own; staff may name network). key defaults to the name, and must read as a slug (1-48 of a-z, 0-9 and -, lowercased); kind defaults to other. Refusals are problem+json: 422 vip.invalid_input (no name, a bad key, kind or binding) or vip.text_too_long; 409 vip.perk_exists (the key is taken); 403 capability.denied or vip.not_yours. Unknown fields are ignored.
Fields
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
creator | one of | The creator the perk belongs to (a user SubjectRef, or network for staff). | ||
key | string |
| ||
name | string | yes |
| |
description | string | null |
| ||
kind | enum |
| ||
bindings | array of object | Replaces the perk's active bindings (a binding left out is removed). Each (product, binding) at most once. |
| |
bindings[].product | string | yes | A service id: live, chat, community, blog, … |
|
bindings[].binding | string | yes | chat_badge, room_access, gated_post, … |
|
bindings[].config | object | null | Under 2 KB of JSON; default {}. |
Examples
From the contract's own test fixtures: valid ones validate, rejected ones must fail.
Valid: badge
{
"creator": {
"type": "user",
"id": "usr_01JAB2C3D4E5F6G7H8J9K0MNPQ"
},
"key": "chat-badge",
"name": "Chat badge",
"description": "A supporter badge next to your name in chat.",
"kind": "badge",
"bindings": [
{
"product": "chat",
"binding": "chat_badge",
"config": {
"icon": "star"
}
}
]
}Rejected: bad-kind
{
"name": "Discount",
"kind": "coupon"
}Validate
const contracts = require('openvibe-contracts');
contracts.validate('vip.perk-create-request@1', value); // { valid, errors: [{ path, message }] }