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

FieldTypeRequiredDescriptionConstraints
creatorone ofThe creator the perk belongs to (a user SubjectRef, or network for staff).
keystring
  • pattern ^[a-z0-9][a-z0-9-]{0,47}$
namestringyes
  • minLength 1
  • maxLength 80
descriptionstring | null
  • maxLength 500
kindenum
  • one of "badge", "emote", "gated_content", "room", "role", "other"
bindingsarray of objectReplaces the perk's active bindings (a binding left out is removed). Each (product, binding) at most once.
  • maxItems 20
bindings[].productstringyesA service id: live, chat, community, blog, …
  • pattern ^[a-z][a-z0-9-]{1,39}$
bindings[].bindingstringyeschat_badge, room_access, gated_post, …
  • pattern ^[a-z][a-z0-9_.]{1,63}$
bindings[].configobject | nullUnder 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 }] }