{
  "openapi": "3.0.3",
  "info": {
    "title": "Rinili Business API",
    "version": "1.0.0",
    "description": "Business integration API for orders, branches and notifications. Contract snapshot 2026-11-02."
  },
  "servers": [
    {
      "url": "https://api.rinili.com"
    }
  ],
  "paths": {
    "/api/v1/orders": {
      "get": {
        "x-deployment-status": "deployed",
        "tags": [
          "Orders"
        ],
        "summary": "List orders",
        "operationId": "orders_list_orders",
        "description": "Newest first, scoped to the restaurant belonging to your key. Defaults to 25 orders per page. Follow links.next until null. Required scope: orders.read.",
        "security": [
          {
            "IntegrationKey": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by order status.",
            "schema": {
              "type": "string",
              "description": "Filter by order status.",
              "enum": [
                "pending",
                "accepted",
                "preparing",
                "ready",
                "completed",
                "cancelled"
              ]
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "description": "Page size, 1–100. Default 25.",
            "schema": {
              "type": "integer",
              "description": "Page size, 1–100. Default 25.",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "Page number, starting at 1.",
            "schema": {
              "type": "integer",
              "description": "Page number, starting at 1.",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "restaurant_id": {
                            "type": "integer"
                          },
                          "branch_id": {
                            "type": "integer"
                          },
                          "reference": {
                            "type": "string"
                          },
                          "customer_name": {
                            "type": "string"
                          },
                          "customer_phone": {
                            "type": "string",
                            "nullable": true
                          },
                          "total": {
                            "type": "string"
                          },
                          "currency": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "items": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string"
                                },
                                "quantity": {
                                  "type": "integer"
                                },
                                "unit_price": {
                                  "type": "number"
                                }
                              }
                            }
                          },
                          "notes": {
                            "type": "string",
                            "nullable": true
                          },
                          "version": {
                            "type": "integer"
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "updated_at": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "links": {
                      "type": "object",
                      "properties": {
                        "first": {
                          "type": "string"
                        },
                        "last": {
                          "type": "string"
                        },
                        "prev": {
                          "type": "string",
                          "nullable": true
                        },
                        "next": {
                          "type": "string",
                          "nullable": true
                        }
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "current_page": {
                          "type": "integer"
                        },
                        "from": {
                          "type": "integer"
                        },
                        "last_page": {
                          "type": "integer"
                        },
                        "path": {
                          "type": "string"
                        },
                        "per_page": {
                          "type": "integer"
                        },
                        "to": {
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": 42,
                      "restaurant_id": 7,
                      "branch_id": 12,
                      "reference": "POS-1042",
                      "customer_name": "Sample customer",
                      "customer_phone": null,
                      "total": "12.50",
                      "currency": "JOD",
                      "status": "pending",
                      "items": [
                        {
                          "name": "Lunch bowl",
                          "quantity": 1,
                          "unit_price": 12.5
                        }
                      ],
                      "notes": null,
                      "version": 1,
                      "created_at": "2026-11-02T09:00:00.000000Z",
                      "updated_at": "2026-11-02T09:00:00.000000Z"
                    }
                  ],
                  "links": {
                    "first": "https://api.rinili.com/api/v1/orders?page=1",
                    "last": "https://api.rinili.com/api/v1/orders?page=1",
                    "prev": null,
                    "next": null
                  },
                  "meta": {
                    "current_page": 1,
                    "from": 1,
                    "last_page": 1,
                    "path": "https://api.rinili.com/api/v1/orders",
                    "per_page": 25,
                    "to": 1,
                    "total": 1
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired authentication."
          },
          "403": {
            "description": "Insufficient scope or access."
          },
          "404": {
            "description": "Missing or inaccessible resource."
          },
          "409": {
            "description": "Version or duplicate conflict."
          },
          "422": {
            "description": "Validation failed."
          },
          "429": {
            "description": "Rate or capacity limit."
          },
          "503": {
            "description": "Service unavailable."
          }
        }
      },
      "post": {
        "x-deployment-status": "deployed",
        "tags": [
          "Orders"
        ],
        "summary": "Create an order",
        "operationId": "orders_create_an_order",
        "description": "Creates a pending order. Do not send restaurant_id: the key determines ownership. Reference must be globally unique; when omitted the server generates RN- followed by a random suffix. Currency defaults to the platform setting or JOD. Platform order-total limits also apply. No general Idempotency-Key support is implemented. Required scope: orders.write.",
        "security": [
          {
            "IntegrationKey": []
          }
        ],
        "parameters": [],
        "responses": {
          "201": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "restaurant_id": {
                          "type": "integer"
                        },
                        "branch_id": {
                          "type": "integer"
                        },
                        "reference": {
                          "type": "string"
                        },
                        "customer_name": {
                          "type": "string"
                        },
                        "customer_phone": {
                          "type": "string",
                          "nullable": true
                        },
                        "total": {
                          "type": "string"
                        },
                        "currency": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "quantity": {
                                "type": "integer"
                              },
                              "unit_price": {
                                "type": "number"
                              }
                            }
                          }
                        },
                        "notes": {
                          "type": "string",
                          "nullable": true
                        },
                        "version": {
                          "type": "integer"
                        },
                        "created_at": {
                          "type": "string"
                        },
                        "updated_at": {
                          "type": "string"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": 42,
                    "restaurant_id": 7,
                    "branch_id": 12,
                    "reference": "POS-1042",
                    "customer_name": "Sample customer",
                    "customer_phone": null,
                    "total": "12.50",
                    "currency": "JOD",
                    "status": "pending",
                    "items": [
                      {
                        "name": "Lunch bowl",
                        "quantity": 1,
                        "unit_price": 12.5
                      }
                    ],
                    "notes": null,
                    "version": 1,
                    "created_at": "2026-11-02T09:00:00.000000Z",
                    "updated_at": "2026-11-02T09:00:00.000000Z"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired authentication."
          },
          "403": {
            "description": "Insufficient scope or access."
          },
          "404": {
            "description": "Missing or inaccessible resource."
          },
          "409": {
            "description": "Version or duplicate conflict."
          },
          "422": {
            "description": "Validation failed."
          },
          "429": {
            "description": "Rate or capacity limit."
          },
          "503": {
            "description": "Service unavailable."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "branch_id": {
                    "type": "integer",
                    "description": "An active, non-deleted branch in your restaurant.",
                    "example": 12
                  },
                  "customer_name": {
                    "type": "string",
                    "description": "Maximum 255 characters.",
                    "maxLength": 255,
                    "example": "Sample customer"
                  },
                  "total": {
                    "type": "number",
                    "description": "Non-negative total, subject to the configured platform limit.",
                    "minimum": 0,
                    "example": 12.5
                  },
                  "reference": {
                    "type": "string",
                    "description": "Optional unique reference. Maximum 100 characters.",
                    "maxLength": 100,
                    "example": "POS-1042"
                  },
                  "customer_phone": {
                    "type": "string",
                    "description": "Optional phone, maximum 40 characters.",
                    "maxLength": 40
                  },
                  "currency": {
                    "type": "string",
                    "description": "Supported ISO currency.",
                    "enum": [
                      "JOD",
                      "USD",
                      "EUR",
                      "SAR",
                      "AED"
                    ],
                    "example": "JOD"
                  },
                  "items": {
                    "type": "array",
                    "description": "Up to 100 items. Each requires name (≤200), quantity (1–1000), unit_price (≥0).",
                    "maxItems": 100,
                    "items": {
                      "type": "object",
                      "required": [
                        "name",
                        "quantity",
                        "unit_price"
                      ],
                      "properties": {
                        "name": {
                          "type": "string",
                          "maxLength": 200
                        },
                        "quantity": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 1000
                        },
                        "unit_price": {
                          "type": "number",
                          "minimum": 0
                        }
                      }
                    },
                    "example": [
                      {
                        "name": "Lunch bowl",
                        "quantity": 1,
                        "unit_price": 12.5
                      }
                    ]
                  },
                  "notes": {
                    "type": "string",
                    "description": "Optional notes, maximum 10,000 characters.",
                    "maxLength": 10000
                  }
                },
                "required": [
                  "branch_id",
                  "customer_name",
                  "total"
                ]
              }
            }
          }
        }
      }
    },
    "/api/v1/orders/{id}": {
      "get": {
        "x-deployment-status": "deployed",
        "tags": [
          "Orders"
        ],
        "summary": "Retrieve an order",
        "operationId": "orders_retrieve_an_order",
        "description": "Returns a single restaurant-owned order. Missing orders and orders outside your restaurant return 404. Required scope: orders.read.",
        "security": [
          {
            "IntegrationKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "restaurant_id": {
                          "type": "integer"
                        },
                        "branch_id": {
                          "type": "integer"
                        },
                        "reference": {
                          "type": "string"
                        },
                        "customer_name": {
                          "type": "string"
                        },
                        "customer_phone": {
                          "type": "string",
                          "nullable": true
                        },
                        "total": {
                          "type": "string"
                        },
                        "currency": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "quantity": {
                                "type": "integer"
                              },
                              "unit_price": {
                                "type": "number"
                              }
                            }
                          }
                        },
                        "notes": {
                          "type": "string",
                          "nullable": true
                        },
                        "version": {
                          "type": "integer"
                        },
                        "created_at": {
                          "type": "string"
                        },
                        "updated_at": {
                          "type": "string"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": 42,
                    "restaurant_id": 7,
                    "branch_id": 12,
                    "reference": "POS-1042",
                    "customer_name": "Sample customer",
                    "customer_phone": null,
                    "total": "12.50",
                    "currency": "JOD",
                    "status": "pending",
                    "items": [
                      {
                        "name": "Lunch bowl",
                        "quantity": 1,
                        "unit_price": 12.5
                      }
                    ],
                    "notes": null,
                    "version": 1,
                    "created_at": "2026-11-02T09:00:00.000000Z",
                    "updated_at": "2026-11-02T09:00:00.000000Z"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired authentication."
          },
          "403": {
            "description": "Insufficient scope or access."
          },
          "404": {
            "description": "Missing or inaccessible resource."
          },
          "409": {
            "description": "Version or duplicate conflict."
          },
          "422": {
            "description": "Validation failed."
          },
          "429": {
            "description": "Rate or capacity limit."
          },
          "503": {
            "description": "Service unavailable."
          }
        }
      }
    },
    "/api/v1/orders/{id}/status": {
      "patch": {
        "x-deployment-status": "deployed",
        "tags": [
          "Orders"
        ],
        "summary": "Update order status",
        "operationId": "orders_update_order_status",
        "description": "Read the current order first. Transitions: pending → accepted → preparing → ready → completed. Cancellation is allowed from non-terminal states only when platform settings permit. Completed and cancelled orders cannot reopen. Invalid transitions return 422; stale versions return 409. Required scope: orders.write.",
        "security": [
          {
            "IntegrationKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "restaurant_id": {
                          "type": "integer"
                        },
                        "branch_id": {
                          "type": "integer"
                        },
                        "reference": {
                          "type": "string"
                        },
                        "customer_name": {
                          "type": "string"
                        },
                        "customer_phone": {
                          "type": "string",
                          "nullable": true
                        },
                        "total": {
                          "type": "string"
                        },
                        "currency": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "quantity": {
                                "type": "integer"
                              },
                              "unit_price": {
                                "type": "number"
                              }
                            }
                          }
                        },
                        "notes": {
                          "type": "string",
                          "nullable": true
                        },
                        "version": {
                          "type": "integer"
                        },
                        "created_at": {
                          "type": "string"
                        },
                        "updated_at": {
                          "type": "string"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": 42,
                    "restaurant_id": 7,
                    "branch_id": 12,
                    "reference": "POS-1042",
                    "customer_name": "Sample customer",
                    "customer_phone": null,
                    "total": "12.50",
                    "currency": "JOD",
                    "status": "accepted",
                    "items": [
                      {
                        "name": "Lunch bowl",
                        "quantity": 1,
                        "unit_price": 12.5
                      }
                    ],
                    "notes": null,
                    "version": 2,
                    "created_at": "2026-11-02T09:00:00.000000Z",
                    "updated_at": "2026-11-02T09:00:00.000000Z"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired authentication."
          },
          "403": {
            "description": "Insufficient scope or access."
          },
          "404": {
            "description": "Missing or inaccessible resource."
          },
          "409": {
            "description": "Version or duplicate conflict."
          },
          "422": {
            "description": "Validation failed."
          },
          "429": {
            "description": "Rate or capacity limit."
          },
          "503": {
            "description": "Service unavailable."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "description": "Next allowed status.",
                    "enum": [
                      "accepted",
                      "preparing",
                      "ready",
                      "completed",
                      "cancelled"
                    ],
                    "example": "accepted"
                  },
                  "version": {
                    "type": "integer",
                    "description": "Current record version from the latest GET. Minimum 1. A stale version returns 409.",
                    "minimum": 1,
                    "example": 1
                  }
                },
                "required": [
                  "status",
                  "version"
                ]
              }
            }
          }
        }
      }
    },
    "/api/v1/branches": {
      "get": {
        "x-deployment-status": "deployed",
        "tags": [
          "Branches"
        ],
        "summary": "List branches",
        "operationId": "branches_list_branches",
        "description": "Returns all non-deleted branches belonging to your restaurant, including inactive branches. Use an active branch to create an order. This endpoint is not paginated. Create and edit branches in the Business Owner dashboard; the API exposes branch listing only. Required scope: branches.read.",
        "security": [
          {
            "IntegrationKey": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "restaurant_id": {
                            "type": "integer"
                          },
                          "name": {
                            "type": "string"
                          },
                          "address": {
                            "type": "string"
                          },
                          "latitude": {
                            "type": "number",
                            "nullable": true
                          },
                          "longitude": {
                            "type": "number",
                            "nullable": true
                          },
                          "phone": {
                            "type": "string",
                            "nullable": true
                          },
                          "status": {
                            "type": "string"
                          },
                          "version": {
                            "type": "integer"
                          },
                          "updated_at": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": 12,
                      "restaurant_id": 7,
                      "name": "Sample branch",
                      "address": "Amman",
                      "latitude": null,
                      "longitude": null,
                      "phone": null,
                      "status": "active",
                      "version": 1,
                      "updated_at": "2026-11-02T09:00:00.000000Z"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired authentication."
          },
          "403": {
            "description": "Insufficient scope or access."
          },
          "404": {
            "description": "Missing or inaccessible resource."
          },
          "409": {
            "description": "Version or duplicate conflict."
          },
          "422": {
            "description": "Validation failed."
          },
          "429": {
            "description": "Rate or capacity limit."
          },
          "503": {
            "description": "Service unavailable."
          }
        }
      }
    },
    "/api/v1/notifications": {
      "post": {
        "x-deployment-status": "deployed",
        "tags": [
          "Notifications"
        ],
        "summary": "Queue a notification",
        "operationId": "notifications_queue_a_notification",
        "description": "Creates a campaign for your restaurant and queues delivery to eligible users. 202 means queued, not device display. Delivery depends on enabled channels, eligible recipients, registered devices and provider configuration. restaurant_id is prohibited. Required scope: notifications.write.",
        "security": [
          {
            "IntegrationKey": []
          }
        ],
        "parameters": [],
        "responses": {
          "202": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "status": {
                      "type": "string"
                    },
                    "recipients": {
                      "type": "integer"
                    }
                  }
                },
                "example": {
                  "id": 31,
                  "status": "queued",
                  "recipients": 2
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired authentication."
          },
          "403": {
            "description": "Insufficient scope or access."
          },
          "404": {
            "description": "Missing or inaccessible resource."
          },
          "409": {
            "description": "Version or duplicate conflict."
          },
          "422": {
            "description": "Validation failed."
          },
          "429": {
            "description": "Rate or capacity limit."
          },
          "503": {
            "description": "Service unavailable."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "description": "Maximum 255 characters.",
                    "maxLength": 255,
                    "example": "Your order is ready"
                  },
                  "body": {
                    "type": "string",
                    "description": "Maximum 10,000 characters.",
                    "maxLength": 10000,
                    "example": "Please collect at the counter."
                  },
                  "channel": {
                    "type": "string",
                    "description": "Delivery channel.",
                    "enum": [
                      "in_app",
                      "push"
                    ],
                    "example": "in_app"
                  }
                },
                "required": [
                  "title",
                  "body",
                  "channel"
                ]
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "IntegrationKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Restaurant-scoped API key. Required scopes are described per operation."
      }
    }
  }
}
