{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/tgpaycrypto-com/json-schema/tgpaycrypto-com-create-check-request-schema.json",
  "title": "CreateCheckRequest",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/tgpaycrypto-com-openapi.json#/components/schemas/CreateCheckRequest",
  "type": "object",
  "required": [
    "asset"
  ],
  "properties": {
    "asset": {
      "type": "string",
      "maxLength": 16
    },
    "amount": {
      "anyOf": [
        {
          "$ref": "#/$defs/AmountInput"
        },
        {
          "type": "null"
        }
      ]
    },
    "pin_to_user_id": {
      "anyOf": [
        {
          "oneOf": [
            {
              "type": "integer",
              "maximum": 9223372036854775807,
              "minimum": 1
            },
            {
              "type": "string",
              "pattern": "^\\s*\\+?0*(?:[1-9][0-9]{0,17}|[1-8][0-9]{18}|9[0-1][0-9]{17}|92[0-1][0-9]{16}|922[0-2][0-9]{15}|9223[0-2][0-9]{14}|92233[0-6][0-9]{13}|922337[0-1][0-9]{12}|92233720[0-2][0-9]{10}|922337203[0-5][0-9]{9}|9223372036[0-7][0-9]{8}|92233720368[0-4][0-9]{7}|922337203685[0-3][0-9]{6}|9223372036854[0-6][0-9]{5}|92233720368547[0-6][0-9]{4}|922337203685477[0-4][0-9]{3}|9223372036854775[0-7][0-9]{2}|922337203685477580[0-6]|9223372036854775807)\\s*$"
            }
          ],
          "description": "Restrict claiming to this Telegram user ID."
        },
        {
          "type": "null"
        }
      ]
    },
    "pin_to_username": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 64,
          "description": "Restrict by @username (leading @ optional, case-insensitive); ignored when pin_to_user_id is also given. Must belong to an existing user of the platform."
        },
        {
          "type": "null"
        }
      ]
    },
    "spend_id": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 64,
          "description": "Optional replay key; empty/null disables idempotency."
        },
        {
          "type": "null"
        }
      ]
    },
    "recipients": {
      "anyOf": [
        {
          "type": "array",
          "minItems": 1,
          "maxItems": 100,
          "items": {
            "$ref": "#/$defs/CheckRecipientRequest"
          },
          "description": "JSON body only. One seat per recipient; sum funds the check. Mutually exclusive with pins."
        },
        {
          "type": "null"
        }
      ]
    },
    "password": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 64,
          "description": "Optional claim password; empty/null means no password. Never returned."
        },
        {
          "type": "null"
        }
      ]
    },
    "expires_in": {
      "anyOf": [
        {
          "oneOf": [
            {
              "type": "integer",
              "maximum": 9223372036854775807,
              "minimum": 0
            },
            {
              "type": "string",
              "pattern": "^\\s*(?:\\+?0*(?:[1-9][0-9]{0,17}|[1-8][0-9]{18}|9[0-1][0-9]{17}|92[0-1][0-9]{16}|922[0-2][0-9]{15}|9223[0-2][0-9]{14}|92233[0-6][0-9]{13}|922337[0-1][0-9]{12}|92233720[0-2][0-9]{10}|922337203[0-5][0-9]{9}|9223372036[0-7][0-9]{8}|92233720368[0-4][0-9]{7}|922337203685[0-3][0-9]{6}|9223372036854[0-6][0-9]{5}|92233720368547[0-6][0-9]{4}|922337203685477[0-4][0-9]{3}|9223372036854775[0-7][0-9]{2}|922337203685477580[0-6]|9223372036854775807)|[+-]?0+)\\s*$"
            }
          ],
          "description": "Seconds until expiry; zero, null or omitted means no explicit deadline. Choose a duration that produces a representable expiry timestamp."
        },
        {
          "type": "null"
        }
      ]
    },
    "description": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 1024,
          "description": "Text shown on the check's page once it passes review; change it with editCheck."
        },
        {
          "type": "null"
        }
      ]
    },
    "payload": {
      "anyOf": [
        {
          "$ref": "#/$defs/OperationPayload"
        },
        {
          "type": "null"
        }
      ]
    },
    "success_url": {
      "anyOf": [
        {
          "$ref": "#/$defs/ReturnUrl",
          "description": "A Return button shown to the person after they claim the check."
        },
        {
          "type": "null"
        }
      ]
    },
    "cancel_url": {
      "anyOf": [
        {
          "$ref": "#/$defs/ReturnUrl",
          "description": "A Return button shown when the person can't claim the check (claimed, expired or not for them)."
        },
        {
          "type": "null"
        }
      ]
    },
    "webhook_url": {
      "anyOf": [
        {
          "$ref": "#/$defs/OperationWebhookUrl"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "anyOf": [
    {
      "required": [
        "amount"
      ],
      "properties": {
        "amount": {
          "not": {
            "type": "null"
          }
        }
      }
    },
    {
      "required": [
        "recipients"
      ],
      "properties": {
        "recipients": {
          "not": {
            "type": "null"
          }
        }
      }
    }
  ],
  "allOf": [
    {
      "if": {
        "required": [
          "recipients"
        ],
        "properties": {
          "recipients": {
            "not": {
              "type": "null"
            }
          }
        }
      },
      "then": {
        "properties": {
          "pin_to_user_id": {
            "type": "null"
          },
          "pin_to_username": {
            "enum": [
              null,
              ""
            ]
          }
        }
      }
    }
  ],
  "$defs": {
    "AmountInput": {
      "type": "string",
      "minLength": 1,
      "maxLength": 40,
      "description": "Positive amount as a decimal string (not a JSON number). Surrounding whitespace and exponent notation are accepted. Crypto rounds to asset precision, midpoint away from zero, and must remain positive; fiat requires exact positive cents. Values must fit the server decimal parser and scaling arithmetic.",
      "pattern": "^\\s*\\+?(?=[0-9.]*[1-9])(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$"
    },
    "CheckRecipientRequest": {
      "type": "object",
      "required": [
        "amount"
      ],
      "properties": {
        "user_id": {
          "anyOf": [
            {
              "oneOf": [
                {
                  "type": "integer",
                  "maximum": 9223372036854775807,
                  "minimum": 1
                },
                {
                  "type": "string",
                  "pattern": "^\\s*\\+?0*(?:[1-9][0-9]{0,17}|[1-8][0-9]{18}|9[0-1][0-9]{17}|92[0-1][0-9]{16}|922[0-2][0-9]{15}|9223[0-2][0-9]{14}|92233[0-6][0-9]{13}|922337[0-1][0-9]{12}|92233720[0-2][0-9]{10}|922337203[0-5][0-9]{9}|9223372036[0-7][0-9]{8}|92233720368[0-4][0-9]{7}|922337203685[0-3][0-9]{6}|9223372036854[0-6][0-9]{5}|92233720368547[0-6][0-9]{4}|922337203685477[0-4][0-9]{3}|9223372036854775[0-7][0-9]{2}|922337203685477580[0-6]|9223372036854775807)\\s*$"
                }
              ],
              "description": "Integer or integer string; parsed value must be within 1..9223372036854775807."
            },
            {
              "type": "null"
            }
          ]
        },
        "username": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 64,
              "description": "Optional leading @, case-insensitive; the normalized handle must start with a letter and contain 4..32 letters, digits or underscores."
            },
            {
              "type": "null"
            }
          ]
        },
        "amount": {
          "$ref": "#/$defs/AmountInput"
        }
      },
      "oneOf": [
        {
          "allOf": [
            {
              "required": [
                "user_id"
              ],
              "properties": {
                "user_id": {
                  "not": {
                    "type": "null"
                  }
                }
              }
            }
          ],
          "properties": {
            "username": {
              "enum": [
                null,
                ""
              ]
            }
          }
        },
        {
          "allOf": [
            {
              "required": [
                "username"
              ],
              "properties": {
                "username": {
                  "not": {
                    "type": "null"
                  }
                }
              }
            }
          ],
          "properties": {
            "user_id": {
              "type": "null"
            },
            "username": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      ]
    },
    "OperationPayload": {
      "type": "string",
      "maxLength": 4096,
      "description": "Your own data, echoed in the object and its webhooks. An empty string means none."
    },
    "OperationWebhookUrl": {
      "type": "string",
      "maxLength": 256,
      "description": "This operation's own webhook address — an absolute public HTTPS URL, no embedded credentials, surrounding spaces trimmed. Every update of the operation goes here instead of the app's webhook URL, regardless of the app's event selection. An empty string means the app's URL. Not returned in objects. With a spend_id it is part of the compared request."
    },
    "ReturnUrl": {
      "type": "string",
      "maxLength": 512,
      "description": "An absolute http:// or https:// URL; surrounding spaces trimmed, an empty string means none."
    }
  }
}