{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://peyeli.com/partner-contracts.json",
  "title": "Peyeli selected application contract shapes",
  "description": "Source-reviewed evaluation snapshot, edition 1.3, 11 October 2026. Not OpenAPI: this file is JSON Schema; the separate OpenAPI describes the synthetic evaluation sandbox. Neither establishes a supported external API, live endpoint grant or production compatibility commitment.",
  "x-interface": "Verified application cookie session; current active organization membership and operation checks. No partner API-key or OAuth product is established by this snapshot.",
  "x-contract-review": "Runtime asset/environment checks, tenant/own-record filters and provider capability checks remain authoritative. JSON Schema describes selected shape constraints only.",
  "x-operations": [
    {
      "method": "POST",
      "path": "/api/v1/orgs/{org}/payment-intents",
      "authority": "payment.create",
      "request": "#/$defs/CreateIntent",
      "response": "#/$defs/IntentView",
      "success": 201,
      "idempotency": "Required; organization + operation containing actor identity + key."
    },
    {
      "method": "GET",
      "path": "/api/v1/orgs/{org}/payment-intents",
      "authority": "payment.view",
      "response": "#/$defs/IntentList",
      "success": 200,
      "query": "status, q (max 120), limit (default 50, max 200 or 1000 with range), from/to (paired inclusive YYYY-MM-DD in America/Port-au-Prince). No cursor."
    },
    {
      "method": "GET",
      "path": "/api/v1/orgs/{org}/payment-intents/{pi}",
      "authority": "payment.view",
      "response": "#/$defs/IntentDetail",
      "success": 200
    },
    {
      "method": "POST",
      "path": "/api/v1/orgs/{org}/payment-intents/{pi}/attempts",
      "authority": "payment.collect",
      "request": "#/$defs/StartAttempt",
      "response": "#/$defs/AttemptCreated",
      "success": 201,
      "idempotency": "Required; operation includes intent and actor identity. Submission is not financial confirmation."
    },
    {
      "method": "POST",
      "path": "/api/v1/orgs/{org}/payment-intents/{pi}/cancel",
      "authority": "payment.cancel",
      "response": "#/$defs/IntentView",
      "success": 200,
      "idempotency": "Required; application/json body required; unresolved attempt blocks cancellation."
    }
  ],
  "$defs": {
    "Money": {
      "type": "object",
      "required": [
        "amountMinor",
        "assetId"
      ],
      "properties": {
        "amountMinor": {
          "type": "string",
          "pattern": "^(0|[1-9][0-9]*|-[1-9][0-9]*)$"
        },
        "assetId": {
          "type": "string"
        }
      }
    },
    "PositiveMoney": {
      "type": "object",
      "required": [
        "amountMinor",
        "assetId"
      ],
      "properties": {
        "amountMinor": {
          "type": "string",
          "pattern": "^[1-9][0-9]*$"
        },
        "assetId": {
          "type": "string",
          "description": "Existing electronic asset compatible with target environment; not physical cash."
        }
      }
    },
    "CreateIntent": {
      "type": "object",
      "required": [
        "amount",
        "orderReference"
      ],
      "properties": {
        "amount": {
          "$ref": "#/$defs/PositiveMoney"
        },
        "orderReference": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120,
          "pattern": "\\S",
          "description": "Nonblank; raw length checked before trimming."
        },
        "description": {
          "type": "string",
          "maxLength": 500
        },
        "expiresInMinutes": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 1,
          "maximum": 10080,
          "default": 30,
          "description": "Omitted or null defaults to 30."
        }
      }
    },
    "IntentView": {
      "type": "object",
      "required": [
        "id",
        "amount",
        "orderReference",
        "description",
        "status",
        "settlementStatus",
        "providerConnectionId",
        "expiresAt",
        "confirmedAt",
        "createdBy",
        "createdAt",
        "environment"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "amount": {
          "$ref": "#/$defs/Money"
        },
        "orderReference": {
          "type": "string"
        },
        "description": {
          "type": [
            "string",
            "null"
          ]
        },
        "status": {
          "enum": [
            "requires_payment",
            "processing",
            "requires_review",
            "succeeded",
            "failed",
            "canceled",
            "expired"
          ]
        },
        "settlementStatus": {
          "type": "string"
        },
        "providerConnectionId": {
          "type": [
            "string",
            "null"
          ]
        },
        "expiresAt": {
          "type": "string",
          "format": "date-time"
        },
        "confirmedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "createdBy": {
          "type": "string"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "environment": {
          "type": "string"
        }
      }
    },
    "IntentList": {
      "type": "object",
      "required": [
        "data"
      ],
      "properties": {
        "data": {
          "type": "array",
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/IntentView"
              },
              {
                "type": "object",
                "required": [
                  "provider",
                  "providerLabel"
                ],
                "properties": {
                  "provider": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "providerLabel": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              }
            ]
          }
        }
      }
    },
    "IntentDetail": {
      "allOf": [
        {
          "$ref": "#/$defs/IntentView"
        },
        {
          "type": "object",
          "required": [
            "attempts",
            "receipt"
          ],
          "properties": {
            "attempts": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "id",
                  "status",
                  "providerReference",
                  "providerTransactionId",
                  "failureReason",
                  "createdAt"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "providerReference": {
                    "type": "string"
                  },
                  "providerTransactionId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "failureReason": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "createdAt": {
                    "type": "string",
                    "format": "date-time"
                  }
                }
              }
            },
            "receipt": {
              "anyOf": [
                {
                  "type": "null"
                },
                {
                  "type": "object",
                  "required": [
                    "id",
                    "number",
                    "confirmedAt"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "number": {
                      "type": "string"
                    },
                    "confirmedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              ]
            }
          }
        }
      ]
    },
    "StartAttempt": {
      "type": "object",
      "required": [
        "providerConnectionId"
      ],
      "properties": {
        "providerConnectionId": {
          "type": "string"
        }
      }
    },
    "AttemptCreated": {
      "type": "object",
      "required": [
        "attemptId",
        "providerReference"
      ],
      "properties": {
        "attemptId": {
          "type": "string"
        },
        "providerReference": {
          "type": "string"
        }
      }
    },
    "Error": {
      "type": "object",
      "required": [
        "error"
      ],
      "properties": {
        "error": {
          "type": "object",
          "required": [
            "code",
            "message",
            "requestId"
          ],
          "properties": {
            "code": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "requestId": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}
