---
agentTools:
  projectIndex: https://cannaflow.readme.io/llms.txt
---

# Get order details for a purchased prescription.

Retrieves the order details linked to a prescription by its ID. Returned data includes order identifier, shipping and tracking details, and a breakdown of order summary. Returns 404 if the prescription hasn't been purchased yet.

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Cannaflow API",
    "version": "v1"
  },
  "servers": [
    {
      "url": "https://api-pharmacy.cannaflow.de/api/v1",
      "description": "production"
    },
    {
      "url": "https://api-pharmacy.sandbox.cannaflow.de/api/v1",
      "description": "sandbox"
    },
    {
      "url": "https://api-pharmacy.cannaflow-staging.de/api/v1",
      "description": "staging"
    }
  ],
  "externalDocs": {
    "url": "https://api-pharmacy.sandbox.cannaflow.de/document/v1"
  },
  "paths": {
    "/prescriptions/{id}/order": {
      "get": {
        "operationId": "prescriptions-getLinkedOrder",
        "summary": "Get order details for a purchased prescription.",
        "description": "Retrieves the order details linked to a prescription by its ID. Returned data includes order identifier, shipping and tracking details, and a breakdown of order summary. Returns 404 if the prescription hasn't been purchased yet.",
        "tags": [
          "Prescriptions"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "description": "ID of the prescription"
            },
            "required": true,
            "description": "ID of the prescription"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Unique identifier of the order"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending",
                        "shipped",
                        "readyForPickup",
                        "failed",
                        "completed",
                        "canceled"
                      ],
                      "description": "Current status of the order"
                    },
                    "shipping": {
                      "type": "object",
                      "properties": {
                        "shippingOptionId": {
                          "type": "string",
                          "description": "ID of the shipping option used for the order"
                        },
                        "trackingNumber": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Tracking number of the order."
                        },
                        "trackingUrl": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "URL to track the order"
                        },
                        "deliveryAddress": {
                          "type": "object",
                          "properties": {
                            "street": {
                              "type": "string",
                              "minLength": 1
                            },
                            "houseNumber": {
                              "type": "string",
                              "minLength": 1
                            },
                            "addressLine2": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "maxLength": 45
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Address line 2 (optional, truncated to 45 chars) - e.g., apartment number, company name, hotel room number, or delivery instructions"
                            },
                            "postalCode": {
                              "type": "string",
                              "minLength": 1,
                              "pattern": "^\\d+$"
                            },
                            "city": {
                              "type": "string",
                              "minLength": 1
                            },
                            "country": {
                              "description": "ISO 3166-1 alpha-2 country code",
                              "type": "string"
                            },
                            "lat": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "long": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": [
                            "street",
                            "houseNumber",
                            "addressLine2",
                            "postalCode",
                            "city",
                            "country"
                          ],
                          "additionalProperties": false,
                          "description": "Delivery or pickup address of the order"
                        },
                        "readyForPickupAt": {
                          "anyOf": [
                            {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Timestamp when the order is ready for pickup. Only available for order with shipping option id self-pick-up."
                        },
                        "requestedDelivery": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "date": {
                                  "type": "string",
                                  "description": "Calendar date in YYYY-MM-DD"
                                },
                                "time": {
                                  "description": "Arrival window on that day. Omit for the whole day.",
                                  "type": "object",
                                  "properties": {
                                    "from": {
                                      "description": "Earliest arrival in HH:mm. Omit for \"by `to`\".",
                                      "type": "string",
                                      "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d$"
                                    },
                                    "to": {
                                      "type": "string",
                                      "pattern": "^(?:(?:0[1-9]|1\\d|2[0-3]):[0-5]\\d|00:(?:0[1-9]|[1-5]\\d)|24:00)$",
                                      "description": "Latest arrival in HH:mm. \"24:00\" means end of day."
                                    }
                                  },
                                  "required": [
                                    "to"
                                  ],
                                  "additionalProperties": false
                                },
                                "timezone": {
                                  "default": "Europe/Berlin",
                                  "description": "IANA timezone of `date` and `time`. Only Europe/Berlin is accepted.",
                                  "type": "string",
                                  "const": "Europe/Berlin"
                                }
                              },
                              "required": [
                                "date",
                                "timezone"
                              ],
                              "additionalProperties": false
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "The patient's delivery wish as sent at checkout. Null when none was sent."
                        }
                      },
                      "required": [
                        "shippingOptionId",
                        "trackingNumber",
                        "trackingUrl",
                        "deliveryAddress",
                        "readyForPickupAt",
                        "requestedDelivery"
                      ],
                      "additionalProperties": false
                    },
                    "summary": {
                      "type": "object",
                      "properties": {
                        "totalFeeCents": {
                          "anyOf": [
                            {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Total fees in cents. Null if not yet available."
                        },
                        "totalCent": {
                          "type": "number",
                          "description": "Total price including taxes and shipping in cents"
                        },
                        "subtotalCent": {
                          "type": "number",
                          "description": "Subtotal price excluding taxes and shipping in cents"
                        },
                        "taxCent": {
                          "type": "number",
                          "description": "Total tax amount including shipping in cents"
                        },
                        "itemsTotalCent": {
                          "type": "number",
                          "description": "Total price of all items in cents"
                        },
                        "itemsSubtotalCent": {
                          "type": "number",
                          "description": "Subtotal price of all items in cents (excluding VAT)"
                        },
                        "itemsTaxTotalCent": {
                          "type": "number",
                          "description": "Total VAT amount for all items in cents"
                        },
                        "shippingTotalCent": {
                          "type": "number",
                          "description": "Total shipping cost in cents"
                        },
                        "shippingSubtotalCent": {
                          "type": "number",
                          "description": "Subtotal shipping cost in cents (excluding VAT)"
                        },
                        "shippingTaxTotalCent": {
                          "type": "number",
                          "description": "VAT amount for shipping in cents"
                        },
                        "originalShippingTotalCent": {
                          "type": "number",
                          "description": "Original shipping cost including VAT before discounts in cents"
                        },
                        "originalShippingSubtotalCent": {
                          "type": "number",
                          "description": "Original shipping cost excluding VAT before discounts in cents"
                        },
                        "originalShippingTaxCent": {
                          "type": "number",
                          "description": "Original shipping VAT amount before discounts in cents"
                        }
                      },
                      "required": [
                        "totalFeeCents",
                        "totalCent",
                        "subtotalCent",
                        "taxCent",
                        "itemsTotalCent",
                        "itemsSubtotalCent",
                        "itemsTaxTotalCent",
                        "shippingTotalCent",
                        "shippingSubtotalCent",
                        "shippingTaxTotalCent",
                        "originalShippingTotalCent",
                        "originalShippingSubtotalCent",
                        "originalShippingTaxCent"
                      ],
                      "additionalProperties": false
                    },
                    "products": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Product identifier. For productType=rxOnly this is the Registry Item ID (e.g. CF0001). For other products types this is the product UUID."
                          },
                          "name": {
                            "type": "string",
                            "description": "Name of the product"
                          },
                          "category": {
                            "type": "string",
                            "description": "Category of the product"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "rxOnly",
                              "standard",
                              "addon",
                              "system"
                            ],
                            "description": "Type of the product (rxOnly, standard, addon, system)"
                          },
                          "quantity": {
                            "type": "number",
                            "description": "Quantity of the product"
                          },
                          "unit": {
                            "type": "string",
                            "enum": [
                              "grams",
                              "milliliters",
                              "pieces"
                            ],
                            "description": "Unit of the product"
                          },
                          "vat": {
                            "type": "number",
                            "description": "VAT rate as a percentage"
                          },
                          "unitPriceCent": {
                            "type": "number",
                            "description": "Price per unit in cents"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "category",
                          "type",
                          "quantity",
                          "unit",
                          "vat",
                          "unitPriceCent"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "invoice": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "description": "Unique identifier of the invoice"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "normal",
                                "cancellation"
                              ],
                              "description": "Type of the invoice"
                            },
                            "createdAt": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time",
                                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Timestamp when the invoice was created"
                            },
                            "billingAddress": {
                              "type": "object",
                              "properties": {
                                "street": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "houseNumber": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "addressLine2": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "maxLength": 45
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ],
                                  "description": "Address line 2 (optional, truncated to 45 chars) - e.g., apartment number, company name, hotel room number, or delivery instructions"
                                },
                                "postalCode": {
                                  "type": "string",
                                  "minLength": 1,
                                  "pattern": "^\\d+$"
                                },
                                "city": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "country": {
                                  "description": "ISO 3166-1 alpha-2 country code",
                                  "type": "string"
                                },
                                "lat": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "long": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              },
                              "required": [
                                "street",
                                "houseNumber",
                                "addressLine2",
                                "postalCode",
                                "city",
                                "country"
                              ],
                              "additionalProperties": false,
                              "description": "Billing address of the order"
                            }
                          },
                          "required": [
                            "id",
                            "type",
                            "createdAt",
                            "billingAddress"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "@deprecated Use `invoices` array instead. Returns the latest invoice for the order."
                    },
                    "invoices": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Unique identifier of the invoice"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "normal",
                              "cancellation"
                            ],
                            "description": "Type of the invoice"
                          },
                          "createdAt": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Timestamp when the invoice was created"
                          },
                          "billingAddress": {
                            "type": "object",
                            "properties": {
                              "street": {
                                "type": "string",
                                "minLength": 1
                              },
                              "houseNumber": {
                                "type": "string",
                                "minLength": 1
                              },
                              "addressLine2": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "maxLength": 45
                                  },
                                  {
                                    "type": "null"
                                  }
                                ],
                                "description": "Address line 2 (optional, truncated to 45 chars) - e.g., apartment number, company name, hotel room number, or delivery instructions"
                              },
                              "postalCode": {
                                "type": "string",
                                "minLength": 1,
                                "pattern": "^\\d+$"
                              },
                              "city": {
                                "type": "string",
                                "minLength": 1
                              },
                              "country": {
                                "description": "ISO 3166-1 alpha-2 country code",
                                "type": "string"
                              },
                              "lat": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "long": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            },
                            "required": [
                              "street",
                              "houseNumber",
                              "addressLine2",
                              "postalCode",
                              "city",
                              "country"
                            ],
                            "additionalProperties": false,
                            "description": "Billing address of the order"
                          }
                        },
                        "required": [
                          "id",
                          "type",
                          "createdAt",
                          "billingAddress"
                        ],
                        "additionalProperties": false
                      },
                      "description": "All invoices for this order in reverse chronological order (newest first). When the pharmacy authorizes the order, a normal invoice is created. If an authorized order is cancelled afterwards, a cancellation invoice is added."
                    },
                    "payment": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "feeCent": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Payment-processing fee in cents. Null if not yet available."
                            },
                            "externalProvider": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Name of the payment provider supplied when creating the prepaid prescription (e.g. \"stripe\", \"mollie\"). Null if not provided."
                            },
                            "referenceId": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Your internal payment reference supplied when creating the prepaid prescription (paymentDetails.referenceId). Null if not provided."
                            },
                            "method": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "credit-card",
                                    "instant-payment",
                                    "self-pick-up",
                                    "klarna",
                                    "sofort",
                                    "direct-transfer",
                                    "zinia",
                                    "paypal",
                                    "bank-transfer",
                                    "google-pay",
                                    "apple-pay",
                                    "pos-prepaid",
                                    "pay-on-delivery"
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Payment method used for the payment. Null when the order was paid externally (prepaid via the telemedicine provider), as no on-platform payment method applies."
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "paid",
                                "pending"
                              ],
                              "description": "Whether the payment has been captured. Orders with payment method self-pick-up stay \"pending\" until paid at the pharmacy."
                            }
                          },
                          "required": [
                            "feeCent",
                            "externalProvider",
                            "referenceId",
                            "method",
                            "status"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Payment details for the order."
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "Timestamp when the order was created"
                    },
                    "canceledAt": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Timestamp when the order was canceled"
                    },
                    "completedAt": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Timestamp when the order was completed"
                    }
                  },
                  "required": [
                    "id",
                    "status",
                    "shipping",
                    "summary",
                    "products",
                    "invoice",
                    "invoices",
                    "payment",
                    "createdAt",
                    "canceledAt",
                    "completedAt"
                  ],
                  "additionalProperties": false,
                  "example": {
                    "id": "123456789",
                    "status": "completed",
                    "createdAt": "2025-01-01T14:45:00.000Z",
                    "completedAt": "2025-01-05T15:45:00.000Z",
                    "canceledAt": null,
                    "shipping": {
                      "shippingOptionId": "dhl-parcel",
                      "trackingNumber": "1234567890",
                      "trackingUrl": "https://www.dhl.de/tracking/1234567890",
                      "deliveryAddress": {
                        "street": "Hauptstraße",
                        "houseNumber": "42",
                        "addressLine2": null,
                        "postalCode": "10115",
                        "city": "Berlin",
                        "country": "DE"
                      },
                      "readyForPickupAt": null,
                      "requestedDelivery": {
                        "date": "2026-10-15",
                        "time": {
                          "from": "14:00",
                          "to": "18:00"
                        },
                        "timezone": "Europe/Berlin"
                      }
                    },
                    "summary": {
                      "totalFeeCents": 150,
                      "totalCent": 2990,
                      "subtotalCent": 2513,
                      "taxCent": 477,
                      "itemsTotalCent": 2500,
                      "itemsSubtotalCent": 2101,
                      "itemsTaxTotalCent": 399,
                      "shippingTotalCent": 490,
                      "shippingSubtotalCent": 412,
                      "shippingTaxTotalCent": 78,
                      "originalShippingTotalCent": 490,
                      "originalShippingTaxCent": 78,
                      "originalShippingSubtotalCent": 412
                    },
                    "products": [
                      {
                        "type": "rxOnly",
                        "id": "CF0001",
                        "name": "420 pharma 30/1 CA Wedding Singer",
                        "category": "flower",
                        "quantity": 10,
                        "unit": "grams",
                        "vat": 19,
                        "unitPriceCent": 1250
                      }
                    ],
                    "invoice": {
                      "id": "INV-2024-0001",
                      "type": "normal",
                      "createdAt": "2025-01-01T18:45:00.000Z",
                      "billingAddress": {
                        "street": "Hauptstraße",
                        "houseNumber": "42",
                        "addressLine2": null,
                        "postalCode": "10115",
                        "city": "Berlin",
                        "country": "DE"
                      }
                    },
                    "invoices": [
                      {
                        "id": "CPR-2025-0020",
                        "type": "normal",
                        "createdAt": "2025-01-01T18:45:00.000Z",
                        "billingAddress": {
                          "street": "Hauptstraße",
                          "houseNumber": "42",
                          "addressLine2": null,
                          "postalCode": "10115",
                          "city": "Berlin",
                          "country": "DE"
                        }
                      },
                      {
                        "id": "CPR-2025-0021",
                        "type": "cancellation",
                        "createdAt": "2025-01-01T18:45:00.000Z",
                        "billingAddress": {
                          "street": "Hauptstraße",
                          "houseNumber": "42",
                          "addressLine2": null,
                          "postalCode": "10115",
                          "city": "Berlin",
                          "country": "DE"
                        }
                      }
                    ],
                    "payment": {
                      "feeCent": 50,
                      "externalProvider": null,
                      "referenceId": null,
                      "method": "credit-card",
                      "status": "paid"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "error.UNAUTHORIZED": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "The error message",
            "example": "Authorization not provided"
          },
          "code": {
            "type": "string",
            "description": "The error code",
            "example": "UNAUTHORIZED"
          },
          "issues": {
            "description": "An array of issues that were responsible for the error",
            "example": [],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string"
                }
              },
              "required": [
                "message"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "message",
          "code"
        ],
        "additionalProperties": false,
        "title": "Authorization not provided error (401)",
        "description": "The error information",
        "example": {
          "code": "UNAUTHORIZED",
          "message": "Authorization not provided",
          "issues": []
        }
      },
      "error.FORBIDDEN": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "The error message",
            "example": "Insufficient access"
          },
          "code": {
            "type": "string",
            "description": "The error code",
            "example": "FORBIDDEN"
          },
          "issues": {
            "description": "An array of issues that were responsible for the error",
            "example": [],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string"
                }
              },
              "required": [
                "message"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "message",
          "code"
        ],
        "additionalProperties": false,
        "title": "Insufficient access error (403)",
        "description": "The error information",
        "example": {
          "code": "FORBIDDEN",
          "message": "Insufficient access",
          "issues": []
        }
      },
      "error.INTERNAL_SERVER_ERROR": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "The error message",
            "example": "Internal server error"
          },
          "code": {
            "type": "string",
            "description": "The error code",
            "example": "INTERNAL_SERVER_ERROR"
          },
          "issues": {
            "description": "An array of issues that were responsible for the error",
            "example": [],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string"
                }
              },
              "required": [
                "message"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "message",
          "code"
        ],
        "additionalProperties": false,
        "title": "Internal server error error (500)",
        "description": "The error information",
        "example": {
          "code": "INTERNAL_SERVER_ERROR",
          "message": "Internal server error",
          "issues": []
        }
      },
      "error.BAD_REQUEST": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "The error message",
            "example": "Invalid input data"
          },
          "code": {
            "type": "string",
            "description": "The error code",
            "example": "BAD_REQUEST"
          },
          "issues": {
            "description": "An array of issues that were responsible for the error",
            "example": [],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string"
                }
              },
              "required": [
                "message"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "message",
          "code"
        ],
        "additionalProperties": false,
        "title": "Invalid input data error (400)",
        "description": "The error information",
        "example": {
          "code": "BAD_REQUEST",
          "message": "Invalid input data",
          "issues": []
        }
      },
      "error.NOT_FOUND": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "The error message",
            "example": "Not found"
          },
          "code": {
            "type": "string",
            "description": "The error code",
            "example": "NOT_FOUND"
          },
          "issues": {
            "description": "An array of issues that were responsible for the error",
            "example": [],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string"
                }
              },
              "required": [
                "message"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "message",
          "code"
        ],
        "additionalProperties": false,
        "title": "Not found error (404)",
        "description": "The error information",
        "example": {
          "code": "NOT_FOUND",
          "message": "Not found",
          "issues": []
        }
      }
    },
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "description": "Access token for the API",
        "name": "x-cannaflow-api-key",
        "in": "header"
      }
    }
  },
  "webhooks": {
    "prescription.checkout_completed": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "requestBody": {
          "description": "Prescription checkout completed event",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "prescription_checkout_completed"
                    ]
                  },
                  "timestamp": {
                    "type": "number",
                    "description": "Unix timestamp"
                  },
                  "prescription": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Prescription ID"
                      },
                      "referenceId": {
                        "type": "string",
                        "description": "Reference ID"
                      }
                    },
                    "required": [
                      "id",
                      "referenceId"
                    ]
                  }
                },
                "required": [
                  "action",
                  "timestamp",
                  "prescription"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event processed successfully"
          }
        }
      }
    },
    "prescription.payment_confirmed": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "requestBody": {
          "description": "Prescription payment confirmed event. Sent when a payment is captured after checkout, e.g. a bank transfer confirmed by the pharmacy or a self-pickup order paid at the pharmacy (POS terminal or cash). Not sent for payments completed during checkout itself. Every order emits exactly one payment signal: prescription_checkout_completed if it was paid during checkout, or prescription_payment_confirmed if the payment was captured afterwards.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "prescription_payment_confirmed"
                    ]
                  },
                  "timestamp": {
                    "type": "number",
                    "description": "Unix timestamp"
                  },
                  "prescription": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Prescription ID"
                      },
                      "referenceId": {
                        "type": "string",
                        "description": "Reference ID"
                      }
                    },
                    "required": [
                      "id",
                      "referenceId"
                    ]
                  }
                },
                "required": [
                  "action",
                  "timestamp",
                  "prescription"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event processed successfully"
          }
        }
      }
    },
    "prescription.authorized": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "requestBody": {
          "description": "Prescription authorized event",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "prescription_authorized"
                    ]
                  },
                  "timestamp": {
                    "type": "number",
                    "description": "Unix timestamp"
                  },
                  "prescription": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Prescription ID"
                      },
                      "referenceId": {
                        "type": "string",
                        "description": "Reference ID"
                      }
                    },
                    "required": [
                      "id",
                      "referenceId"
                    ]
                  },
                  "invoiceId": {
                    "type": "string",
                    "description": "Invoice ID"
                  }
                },
                "required": [
                  "action",
                  "timestamp",
                  "prescription",
                  "invoiceId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event processed successfully"
          }
        }
      }
    },
    "prescription.packaged": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "requestBody": {
          "description": "Prescription packaged event. Opt-in replacement for `prescription.authorized`, enabled per telemedicine provider — you receive one or the other, never both.  `prescription.authorized` can only be sent when an invoice is created, so orders that are never invoiced at packaging (patient invoicing disabled, or payment collected later such as pay on delivery and pay at pickup) produce no event at all. This event is sent for every packaged order instead, with `invoiceId` null when no invoice exists yet.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "prescription_packaged"
                    ]
                  },
                  "timestamp": {
                    "type": "number",
                    "description": "Unix timestamp"
                  },
                  "prescription": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Prescription ID"
                      },
                      "referenceId": {
                        "type": "string",
                        "description": "Reference ID"
                      }
                    },
                    "required": [
                      "id",
                      "referenceId"
                    ]
                  },
                  "invoiceId": {
                    "type": "string",
                    "nullable": true,
                    "description": "Invoice ID, or null when the order has no invoice at packaging"
                  }
                },
                "required": [
                  "action",
                  "timestamp",
                  "prescription",
                  "invoiceId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event processed successfully"
          }
        }
      }
    },
    "prescription.cancelled": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "requestBody": {
          "description": "Prescription cancelled event",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "prescription_cancelled"
                    ]
                  },
                  "timestamp": {
                    "type": "number",
                    "description": "Unix timestamp"
                  },
                  "prescription": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Prescription ID"
                      },
                      "referenceId": {
                        "type": "string",
                        "description": "Reference ID"
                      }
                    },
                    "required": [
                      "id",
                      "referenceId"
                    ]
                  },
                  "reason": {
                    "type": "string",
                    "description": "Cancellation reason"
                  },
                  "cancelledBy": {
                    "type": "string",
                    "enum": [
                      "telemedicineProvider",
                      "pharmacy"
                    ]
                  },
                  "refundedAmountCent": {
                    "type": "number",
                    "description": "Refunded amount in cents. If payment method supports it this amount was refunded to the patient."
                  },
                  "patientEmailSuppressed": {
                    "type": "boolean",
                    "description": "Only present when cancelledBy is \"pharmacy\". Indicates that the pharmacy suppressed the cancellation email to the patient. This is only relevant if you have disabled Cannaflow's transactional email notifications and handle patient communication yourself."
                  }
                },
                "required": [
                  "action",
                  "timestamp",
                  "prescription",
                  "reason",
                  "cancelledBy",
                  "refundedAmountCent"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event processed successfully"
          }
        }
      }
    },
    "prescription.completed": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "requestBody": {
          "description": "Prescription completed event",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "prescription_completed"
                    ]
                  },
                  "timestamp": {
                    "type": "number",
                    "description": "Unix timestamp"
                  },
                  "prescription": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Prescription ID"
                      },
                      "referenceId": {
                        "type": "string",
                        "description": "Reference ID"
                      }
                    },
                    "required": [
                      "id",
                      "referenceId"
                    ]
                  }
                },
                "required": [
                  "action",
                  "timestamp",
                  "prescription"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event processed successfully"
          }
        }
      }
    },
    "prescription.ready_for_pickup": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "requestBody": {
          "description": "Prescription ready for pickup event",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "prescription_ready_for_pickup"
                    ]
                  },
                  "timestamp": {
                    "type": "number",
                    "description": "Unix timestamp"
                  },
                  "prescription": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Prescription ID"
                      },
                      "referenceId": {
                        "type": "string",
                        "description": "Reference ID"
                      }
                    },
                    "required": [
                      "id",
                      "referenceId"
                    ]
                  },
                  "readyForPickupAt": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Timestamp when the prescription became ready for pickup"
                  }
                },
                "required": [
                  "action",
                  "timestamp",
                  "prescription",
                  "readyForPickupAt"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event processed successfully"
          }
        }
      }
    },
    "prescription.announced": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "requestBody": {
          "description": "Prescription announced event.The package was registered by the pharmacy to the fulfillment provider.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "prescription_announced"
                    ]
                  },
                  "timestamp": {
                    "type": "number",
                    "description": "Unix timestamp"
                  },
                  "prescription": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Prescription ID"
                      },
                      "referenceId": {
                        "type": "string",
                        "description": "Reference ID"
                      }
                    },
                    "required": [
                      "id",
                      "referenceId"
                    ]
                  },
                  "tracking": {
                    "type": "object",
                    "nullable": true,
                    "properties": {
                      "trackingNumber": {
                        "type": "string",
                        "nullable": true,
                        "description": "Tracking number"
                      },
                      "trackingUrl": {
                        "type": "string",
                        "nullable": true,
                        "description": "Tracking URL"
                      }
                    }
                  },
                  "shippingOption": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Option ID"
                      },
                      "type": {
                        "type": "string",
                        "description": "Option type"
                      }
                    },
                    "required": [
                      "id",
                      "type"
                    ]
                  }
                },
                "required": [
                  "action",
                  "timestamp",
                  "prescription",
                  "shippingOption"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event processed successfully"
          }
        }
      }
    },
    "prescription.checkout_payment_failed": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "deprecated": true,
        "summary": "Payment failed (deprecated)",
        "description": "This webhook is no longer in use and should be ignored. Please contact our support team for assistance with payment failure handling.",
        "requestBody": {
          "description": "Payment failed event (deprecated)",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "prescription_checkout_payment_failed"
                    ]
                  },
                  "timestamp": {
                    "type": "number",
                    "description": "Unix timestamp"
                  },
                  "prescription": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "nullable": true,
                        "description": "Prescription ID. Null for draft/TP-initiated checkouts."
                      },
                      "referenceId": {
                        "type": "string",
                        "description": "Reference ID"
                      }
                    },
                    "required": [
                      "id",
                      "referenceId"
                    ]
                  }
                },
                "required": [
                  "action",
                  "timestamp",
                  "prescription"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event processed successfully"
          }
        }
      }
    },
    "prescription.shipped": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "requestBody": {
          "description": "Prescription shipped event",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "prescription_shipped"
                    ]
                  },
                  "timestamp": {
                    "type": "number",
                    "description": "Unix timestamp"
                  },
                  "prescription": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Prescription ID"
                      },
                      "referenceId": {
                        "type": "string",
                        "description": "Reference ID"
                      }
                    },
                    "required": [
                      "id",
                      "referenceId"
                    ]
                  },
                  "tracking": {
                    "type": "object",
                    "nullable": true,
                    "properties": {
                      "trackingNumber": {
                        "type": "string",
                        "nullable": true,
                        "description": "Tracking number"
                      },
                      "trackingUrl": {
                        "type": "string",
                        "nullable": true,
                        "description": "Tracking URL"
                      },
                      "currentLocationDriver": {
                        "type": "object",
                        "nullable": true,
                        "properties": {
                          "lat": {
                            "type": "number",
                            "nullable": true,
                            "description": "Driver lat"
                          },
                          "long": {
                            "type": "number",
                            "nullable": true,
                            "description": "Driver long"
                          }
                        }
                      }
                    }
                  },
                  "shippingOption": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Option ID"
                      },
                      "type": {
                        "type": "string",
                        "description": "Option type"
                      }
                    },
                    "required": [
                      "id",
                      "type"
                    ]
                  },
                  "estimatedDelivery": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": true,
                    "description": "Estimated delivery"
                  }
                },
                "required": [
                  "action",
                  "timestamp",
                  "prescription",
                  "shippingOption"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event processed successfully"
          }
        }
      }
    },
    "prescription.billing_address_updated": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "requestBody": {
          "description": "Prescription billing address updated event. Sent when the pharmacy updates the billing address on an order.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "prescription_billing_address_updated"
                    ]
                  },
                  "timestamp": {
                    "type": "number",
                    "description": "Unix timestamp"
                  },
                  "prescription": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Prescription ID"
                      },
                      "referenceId": {
                        "type": "string",
                        "description": "Reference ID"
                      }
                    },
                    "required": [
                      "id",
                      "referenceId"
                    ]
                  },
                  "previousBillingAddress": {
                    "type": "object",
                    "properties": {
                      "firstName": {
                        "type": "string"
                      },
                      "lastName": {
                        "type": "string"
                      },
                      "street": {
                        "type": "string"
                      },
                      "houseNumber": {
                        "type": "string"
                      },
                      "addressLine2": {
                        "type": "string",
                        "nullable": true
                      },
                      "postalCode": {
                        "type": "string"
                      },
                      "city": {
                        "type": "string"
                      },
                      "country": {
                        "type": "string"
                      },
                      "lat": {
                        "type": "number",
                        "nullable": true,
                        "description": "Latitude"
                      },
                      "long": {
                        "type": "number",
                        "nullable": true,
                        "description": "Longitude"
                      }
                    },
                    "required": [
                      "firstName",
                      "lastName",
                      "street",
                      "houseNumber",
                      "addressLine2",
                      "postalCode",
                      "city",
                      "country",
                      "lat",
                      "long"
                    ]
                  },
                  "billingAddress": {
                    "type": "object",
                    "properties": {
                      "firstName": {
                        "type": "string"
                      },
                      "lastName": {
                        "type": "string"
                      },
                      "street": {
                        "type": "string"
                      },
                      "houseNumber": {
                        "type": "string"
                      },
                      "addressLine2": {
                        "type": "string",
                        "nullable": true
                      },
                      "postalCode": {
                        "type": "string"
                      },
                      "city": {
                        "type": "string"
                      },
                      "country": {
                        "type": "string"
                      },
                      "lat": {
                        "type": "number",
                        "nullable": true,
                        "description": "Latitude"
                      },
                      "long": {
                        "type": "number",
                        "nullable": true,
                        "description": "Longitude"
                      }
                    },
                    "required": [
                      "firstName",
                      "lastName",
                      "street",
                      "houseNumber",
                      "addressLine2",
                      "postalCode",
                      "city",
                      "country",
                      "lat",
                      "long"
                    ]
                  }
                },
                "required": [
                  "action",
                  "timestamp",
                  "prescription",
                  "previousBillingAddress",
                  "billingAddress"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event processed successfully"
          }
        }
      }
    },
    "affiliation.activated": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "requestBody": {
          "description": "Affiliation activated event. Sent when a pharmacy switches a telemedicine provider on (the onboarding trigger). Carries a fixed snapshot of the pharmacy onboarding data so the provider can complete onboarding without a separate API round-trip. Opt-in per provider and only sent when a webhook URL is configured.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "affiliation_activated"
                    ]
                  },
                  "timestamp": {
                    "type": "number",
                    "description": "Unix timestamp"
                  },
                  "affiliation": {
                    "type": "object",
                    "properties": {
                      "pharmacyId": {
                        "type": "string",
                        "description": "Cannaflow's canonical pharmacy ID. Always present."
                      },
                      "telemedicineProviderId": {
                        "type": "string",
                        "description": "Telemedicine provider ID."
                      },
                      "externalPharmacyId": {
                        "type": "string",
                        "nullable": true,
                        "description": "The TP's own pharmacy ID. On affiliation_activated this is typically null for TPs that assign it during onboarding — its absence is not an error."
                      }
                    },
                    "required": [
                      "pharmacyId",
                      "telemedicineProviderId",
                      "externalPharmacyId"
                    ]
                  },
                  "pharmacy": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "officialName": {
                        "type": "string"
                      },
                      "slug": {
                        "type": "string"
                      },
                      "contactEmail": {
                        "type": "string"
                      },
                      "contactPhone": {
                        "type": "string",
                        "nullable": true
                      },
                      "website": {
                        "type": "string",
                        "nullable": true
                      },
                      "address": {
                        "type": "object",
                        "properties": {
                          "street": {
                            "type": "string"
                          },
                          "houseNumber": {
                            "type": "string"
                          },
                          "postalCode": {
                            "type": "string"
                          },
                          "city": {
                            "type": "string"
                          },
                          "country": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "street",
                          "houseNumber",
                          "postalCode",
                          "city",
                          "country"
                        ],
                        "description": "Operating address (where the pharmacy is / ships from)."
                      },
                      "billing": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "ownerName": {
                            "type": "string"
                          },
                          "email": {
                            "type": "string"
                          },
                          "taxNumber": {
                            "type": "string",
                            "nullable": true
                          },
                          "vatNumber": {
                            "type": "string",
                            "nullable": true
                          },
                          "address": {
                            "type": "object",
                            "properties": {
                              "street": {
                                "type": "string"
                              },
                              "houseNumber": {
                                "type": "string"
                              },
                              "postalCode": {
                                "type": "string"
                              },
                              "city": {
                                "type": "string"
                              },
                              "country": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "street",
                              "houseNumber",
                              "postalCode",
                              "city",
                              "country"
                            ],
                            "description": "Billing address (where invoices go)."
                          }
                        },
                        "required": [
                          "name",
                          "ownerName",
                          "email",
                          "address"
                        ]
                      }
                    },
                    "required": [
                      "name",
                      "officialName",
                      "slug",
                      "contactEmail",
                      "address",
                      "billing"
                    ]
                  }
                },
                "required": [
                  "action",
                  "timestamp",
                  "affiliation",
                  "pharmacy"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event processed successfully"
          }
        }
      }
    },
    "affiliation.deactivated": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "requestBody": {
          "description": "Affiliation deactivated event. Sent when a pharmacy switches a telemedicine provider off. Carries only the affiliation identifier (no pharmacy data block). Opt-in per provider and only sent when a webhook URL is configured.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "affiliation_deactivated"
                    ]
                  },
                  "timestamp": {
                    "type": "number",
                    "description": "Unix timestamp"
                  },
                  "affiliation": {
                    "type": "object",
                    "properties": {
                      "pharmacyId": {
                        "type": "string",
                        "description": "Cannaflow's canonical pharmacy ID. Always present."
                      },
                      "telemedicineProviderId": {
                        "type": "string",
                        "description": "Telemedicine provider ID."
                      },
                      "externalPharmacyId": {
                        "type": "string",
                        "nullable": true,
                        "description": "The TP's own pharmacy ID. On affiliation_activated this is typically null for TPs that assign it during onboarding — its absence is not an error."
                      }
                    },
                    "required": [
                      "pharmacyId",
                      "telemedicineProviderId",
                      "externalPharmacyId"
                    ]
                  }
                },
                "required": [
                  "action",
                  "timestamp",
                  "affiliation"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event processed successfully"
          }
        }
      }
    },
    "prescription.delivery_address_updated": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "requestBody": {
          "description": "Prescription delivery address updated event. Sent when the pharmacy updates the delivery address on an order.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "prescription_delivery_address_updated"
                    ]
                  },
                  "timestamp": {
                    "type": "number",
                    "description": "Unix timestamp"
                  },
                  "prescription": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Prescription ID"
                      },
                      "referenceId": {
                        "type": "string",
                        "description": "Reference ID"
                      }
                    },
                    "required": [
                      "id",
                      "referenceId"
                    ]
                  },
                  "previousDeliveryAddress": {
                    "type": "object",
                    "properties": {
                      "firstName": {
                        "type": "string"
                      },
                      "lastName": {
                        "type": "string"
                      },
                      "street": {
                        "type": "string"
                      },
                      "houseNumber": {
                        "type": "string"
                      },
                      "addressLine2": {
                        "type": "string",
                        "nullable": true
                      },
                      "postalCode": {
                        "type": "string"
                      },
                      "city": {
                        "type": "string"
                      },
                      "country": {
                        "type": "string"
                      },
                      "lat": {
                        "type": "number",
                        "nullable": true,
                        "description": "Latitude"
                      },
                      "long": {
                        "type": "number",
                        "nullable": true,
                        "description": "Longitude"
                      }
                    },
                    "required": [
                      "firstName",
                      "lastName",
                      "street",
                      "houseNumber",
                      "addressLine2",
                      "postalCode",
                      "city",
                      "country",
                      "lat",
                      "long"
                    ]
                  },
                  "deliveryAddress": {
                    "type": "object",
                    "properties": {
                      "firstName": {
                        "type": "string"
                      },
                      "lastName": {
                        "type": "string"
                      },
                      "street": {
                        "type": "string"
                      },
                      "houseNumber": {
                        "type": "string"
                      },
                      "addressLine2": {
                        "type": "string",
                        "nullable": true
                      },
                      "postalCode": {
                        "type": "string"
                      },
                      "city": {
                        "type": "string"
                      },
                      "country": {
                        "type": "string"
                      },
                      "lat": {
                        "type": "number",
                        "nullable": true,
                        "description": "Latitude"
                      },
                      "long": {
                        "type": "number",
                        "nullable": true,
                        "description": "Longitude"
                      }
                    },
                    "required": [
                      "firstName",
                      "lastName",
                      "street",
                      "houseNumber",
                      "addressLine2",
                      "postalCode",
                      "city",
                      "country",
                      "lat",
                      "long"
                    ]
                  }
                },
                "required": [
                  "action",
                  "timestamp",
                  "prescription",
                  "previousDeliveryAddress",
                  "deliveryAddress"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event processed successfully"
          }
        }
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 103,
      "1": 44,
      "2": 25,
      "3": 148,
      "4": 73,
      "5": 233,
      "6": 9,
      "7": 0,
      "8": 61,
      "9": 87,
      "10": 29,
      "11": 226
    }
  }
}
```