{
  "components": {
    "schemas": {
      "CancelPaymentLink400ErrorCode": {
        "enum": [
          "validation_error"
        ],
        "type": "string"
      },
      "CancelPaymentLink401ErrorCode": {
        "enum": [
          "api_key_missing",
          "invalid_api_key"
        ],
        "type": "string"
      },
      "CancelPaymentLink403ErrorCode": {
        "enum": [
          "provider_disconnected"
        ],
        "type": "string"
      },
      "CancelPaymentLink404ErrorCode": {
        "enum": [
          "payment_link_not_found"
        ],
        "type": "string"
      },
      "CancelPaymentLink409ErrorCode": {
        "enum": [
          "payment_link_not_cancelable"
        ],
        "type": "string"
      },
      "CancelPaymentLink502ErrorCode": {
        "enum": [
          "provider_unavailable"
        ],
        "type": "string"
      },
      "CreatePaymentLink400ErrorCode": {
        "enum": [
          "amount_above_maximum",
          "amount_below_minimum",
          "currency_not_supported",
          "idempotency_key_required",
          "validation_error"
        ],
        "type": "string"
      },
      "CreatePaymentLink401ErrorCode": {
        "enum": [
          "api_key_missing",
          "invalid_api_key"
        ],
        "type": "string"
      },
      "CreatePaymentLink403ErrorCode": {
        "enum": [
          "provider_disconnected",
          "provider_not_connected"
        ],
        "type": "string"
      },
      "CreatePaymentLink409ErrorCode": {
        "enum": [
          "idempotency_key_in_use"
        ],
        "type": "string"
      },
      "CreatePaymentLink415ErrorCode": {
        "enum": [
          "unsupported_media_type"
        ],
        "type": "string"
      },
      "CreatePaymentLink422ErrorCode": {
        "enum": [
          "idempotency_key_mismatch"
        ],
        "type": "string"
      },
      "CreatePaymentLink502ErrorCode": {
        "enum": [
          "provider_unavailable"
        ],
        "type": "string"
      },
      "Error": {
        "properties": {
          "error": {
            "properties": {
              "code": {
                "enum": [
                  "amount_above_maximum",
                  "amount_below_minimum",
                  "api_key_missing",
                  "currency_not_supported",
                  "idempotency_key_in_use",
                  "idempotency_key_mismatch",
                  "idempotency_key_required",
                  "internal_error",
                  "invalid_api_key",
                  "method_not_allowed",
                  "payment_link_not_cancelable",
                  "payment_link_not_found",
                  "provider_disconnected",
                  "provider_not_connected",
                  "provider_unavailable",
                  "route_not_found",
                  "unsupported_media_type",
                  "validation_error",
                  "webhook_signature_invalid"
                ],
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "params": {
                "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                "items": {
                  "$ref": "#/components/schemas/ErrorParam"
                },
                "type": "array"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "ErrorParam": {
        "properties": {
          "message": {
            "type": "string"
          },
          "name": {
            "description": "The request field the message is about, dot-separated when nested.",
            "examples": [
              "amount"
            ],
            "type": "string"
          }
        },
        "required": [
          "name",
          "message"
        ],
        "type": "object"
      },
      "GetPaymentLink400ErrorCode": {
        "enum": [
          "validation_error"
        ],
        "type": "string"
      },
      "GetPaymentLink401ErrorCode": {
        "enum": [
          "api_key_missing",
          "invalid_api_key"
        ],
        "type": "string"
      },
      "GetPaymentLink403ErrorCode": {
        "enum": [
          "provider_disconnected"
        ],
        "type": "string"
      },
      "GetPaymentLink404ErrorCode": {
        "enum": [
          "payment_link_not_found"
        ],
        "type": "string"
      },
      "GetPaymentLink502ErrorCode": {
        "enum": [
          "provider_unavailable"
        ],
        "type": "string"
      },
      "PaymentLink": {
        "properties": {
          "amount": {
            "description": "In the currency's smallest unit: 4900 is $49.00.",
            "examples": [
              4900
            ],
            "type": "integer"
          },
          "created_at": {
            "examples": [
              "2026-12-05T17:40:12.000Z"
            ],
            "format": "date-time",
            "type": "string"
          },
          "currency": {
            "description": "A three-letter ISO 4217 code, uppercase.",
            "examples": [
              "USD"
            ],
            "type": "string"
          },
          "customer_name": {
            "description": "Who the payment is from, as the business named them.",
            "examples": [
              "Ada Lovelace"
            ],
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "examples": [
              "Logo design"
            ],
            "type": "string"
          },
          "id": {
            "examples": [
              "pl_019d0a1b2c3d4e5f60718293a4b5c6d7"
            ],
            "type": "string"
          },
          "status": {
            "description": "`pending` until the customer pays, `processing` while the payment clears, then `paid`. `canceled` once canceled.",
            "enum": [
              "pending",
              "processing",
              "paid",
              "canceled"
            ],
            "examples": [
              "pending"
            ],
            "type": "string"
          },
          "url": {
            "description": "The payment page. Send it to the customer, or pass it to `Cyan.mount` to show the checkout in your page. Keep its query string: `wallets` lists the wallet buttons the checkout makes room for.",
            "examples": [
              "https://pay.cyan.cash/pl_019d0a1b2c3d4e5f60718293a4b5c6d7?wallets=apple_pay"
            ],
            "type": "string"
          }
        },
        "required": [
          "id",
          "amount",
          "currency",
          "description",
          "customer_name",
          "status",
          "url",
          "created_at"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "apiKey": {
        "description": "Your Cyan API key, from the API keys page of the Cyan app: `Authorization: Bearer cyan_test_…`.",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "description": "Payment links for businesses. The URL prefix (`/v1`) is the version contract.",
    "title": "Cyan API",
    "version": "v1"
  },
  "openapi": "3.1.0",
  "paths": {
    "/v1/payment-links": {
      "post": {
        "description": "Creates a payment link and returns it with the URL of its payment page. The request needs an `Idempotency-Key` header. Sending the same key and body again returns the same link, and the same key with a different body returns `idempotency_key_mismatch`.",
        "operationId": "createPaymentLink",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "description": "A key you choose for this request, up to 255 characters. A retry with the same key and body returns the same result.",
              "examples": [
                "order-8412"
              ],
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "amount": {
                    "description": "In the currency's smallest unit: 4900 is $49.00.",
                    "examples": [
                      4900
                    ],
                    "maximum": 99999999,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "currency": {
                    "description": "A three-letter ISO 4217 code. Defaults to USD.",
                    "examples": [
                      "USD"
                    ],
                    "pattern": "^[A-Za-z]{3}$",
                    "type": "string"
                  },
                  "customer_name": {
                    "description": "Who the payment is from. The payment page shows it.",
                    "examples": [
                      "Ada Lovelace"
                    ],
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "description": {
                    "description": "What the payment is for. The customer sees it.",
                    "examples": [
                      "Logo design"
                    ],
                    "maxLength": 200,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "amount",
                  "description"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLink"
                }
              }
            },
            "description": "The created payment link."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/CreatePaymentLink400ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Bad Request: `error.code` is one of `amount_above_maximum`, `amount_below_minimum`, `currency_not_supported`, `idempotency_key_required`, `validation_error`."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/CreatePaymentLink401ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Unauthorized: `error.code` is one of `api_key_missing`, `invalid_api_key`."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/CreatePaymentLink403ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Forbidden: `error.code` is one of `provider_disconnected`, `provider_not_connected`."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/CreatePaymentLink409ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Conflict: `error.code` is `idempotency_key_in_use`."
          },
          "415": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/CreatePaymentLink415ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Unsupported Media Type: `error.code` is `unsupported_media_type`."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/CreatePaymentLink422ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Unprocessable Content: `error.code` is `idempotency_key_mismatch`."
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/CreatePaymentLink502ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Bad Gateway: `error.code` is `provider_unavailable`."
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Create a payment link"
      }
    },
    "/v1/payment-links/{id}": {
      "get": {
        "description": "Returns a payment link of this business, with its status as the payment provider reports it now.",
        "operationId": "getPaymentLink",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "examples": [
                "pl_019d0a1b2c3d4e5f60718293a4b5c6d7"
              ],
              "pattern": "^pl_[0-9a-f]{32}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLink"
                }
              }
            },
            "description": "The payment link."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/GetPaymentLink400ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Bad Request: `error.code` is `validation_error`."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/GetPaymentLink401ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Unauthorized: `error.code` is one of `api_key_missing`, `invalid_api_key`."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/GetPaymentLink403ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Forbidden: `error.code` is `provider_disconnected`."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/GetPaymentLink404ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Not Found: `error.code` is `payment_link_not_found`."
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/GetPaymentLink502ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Bad Gateway: `error.code` is `provider_unavailable`."
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Retrieve a payment link"
      }
    },
    "/v1/payment-links/{id}/cancel": {
      "post": {
        "description": "Cancels a payment link that hasn't been paid, and returns it. Its payment page stops taking payments. Canceling a canceled link returns it unchanged, so a retry is safe. A link that is `processing` or `paid` returns `payment_link_not_cancelable`.",
        "operationId": "cancelPaymentLink",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "examples": [
                "pl_019d0a1b2c3d4e5f60718293a4b5c6d7"
              ],
              "pattern": "^pl_[0-9a-f]{32}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLink"
                }
              }
            },
            "description": "The canceled payment link."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/CancelPaymentLink400ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Bad Request: `error.code` is `validation_error`."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/CancelPaymentLink401ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Unauthorized: `error.code` is one of `api_key_missing`, `invalid_api_key`."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/CancelPaymentLink403ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Forbidden: `error.code` is `provider_disconnected`."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/CancelPaymentLink404ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Not Found: `error.code` is `payment_link_not_found`."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/CancelPaymentLink409ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Conflict: `error.code` is `payment_link_not_cancelable`."
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "$ref": "#/components/schemas/CancelPaymentLink502ErrorCode"
                        },
                        "message": {
                          "type": "string"
                        },
                        "params": {
                          "description": "Each invalid request field, with its own message. Present only on a validation_error.",
                          "items": {
                            "$ref": "#/components/schemas/ErrorParam"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Bad Gateway: `error.code` is `provider_unavailable`."
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Cancel a payment link"
      }
    }
  },
  "servers": [
    {
      "url": "https://api.cyan.cash"
    }
  ]
}
