# Prof API — full reference for agents (v1.0.0) Base URL: https://prof-api.silverthinking.net/v1 Auth: header `Authorization: Bearer prof_live_…` (a token made in Prof → Settings → API & integrations). Success: {"data": …} (+ "pagination" on lists). Failure: {"error": {"code", "message", "details", "request_id"}}. Dates out: ISO 8601 UTC. Dates in: YYYY-MM-DD. Lists: limit 1–100 (default 25), offset; newest first. Rate limit: per token 60 units/min and 20000/day by default (read 1, list>50 rows 3, write 2). 429 + Retry-After when over. Send Idempotency-Key (UUID) on every POST and reuse it on retries. The token has fixed permissions and branches and is never an admin; the server applies the app's rules (stock, prices, unique phones, vault money...). A refused write returns 422 with the app's error code. Delete a whole bill, never a single line. Writes are stamped created_by/edited_by = "API · ". MCP: the same endpoints are MCP tools at https://prof-api.silverthinking.net/mcp (Streamable HTTP, same Authorization header). Tool name = route id with _ (customers_list, sales_bills_create); arguments = the path code + query + body fields (+ optional idempotency_key on writes). Sync: GET /v1/events?after= (or webhooks signed with Prof-Signature: t=,v1=hex(hmac_sha256(secret, t + '.' + body))). ## Endpoints ### GET /v1/me The token itself: its name, permissions, branches, expiry and rate limits. ### GET /v1/branches The branches this token may work in. ### GET /v1/warehouses Warehouses, with the branches each one serves. ### GET /v1/vaults Vaults (cash boxes) per branch. No balances. ### GET /v1/payment-methods Payment methods (InstaPay, wallets, cards...). ### GET /v1/categories Product categories. ### GET /v1/customers Customers, newest first, with what each one owes. Permissions: view_customers - Query `search` (string): Name, phone, company or code. - Query `limit` (integer): Rows per page, 1–100 (default 25). More than 50 costs 3 units. - Query `offset` (integer): Rows to skip (default 0). ### GET /v1/customers/{code} One customer. Permissions: view_customers ### POST /v1/customers Add a customer. The code is given automatically. A phone another customer or supplier already has is refused. Permissions: add_customer, view_customers - Body `name` (string, required): The name. - Body `phone` (string): Mobile number, e.g. 01012345678. - Body `phone2` (string): A second mobile number. - Body `company` (string): Company. - Body `address` (string): Address. - Body `gender` (string: male|female): Gender (some accounts require it). - Body `opening_balance` (number): What the customer already owes from before (0 if nothing). - Body `notes` (string): Notes. - Body `allow_similar` (boolean): false (default): a customer with the same name is reported (409 SIMILAR_RECORDS_EXIST) instead of added. true: add anyway. ### PATCH /v1/customers/{code} Change a customer. Only the fields sent change; an empty string clears a field. Permissions: edit_customer, view_customers - Body `name` (string): Name. - Body `phone` (string): Phone. - Body `phone2` (string): Second phone. - Body `company` (string): Company. - Body `address` (string): Address. - Body `gender` (string: male|female): Gender. - Body `notes` (string): Notes. ### DELETE /v1/customers/{code} Delete a customer. Refused (CUSTOMER_HAS_BILLS) once the customer has any bill, like in the app. Permissions: delete_customer ### GET /v1/suppliers Suppliers, newest first, with what is owed to each one. Permissions: view_suppliers - Query `search` (string): Name, phone, company or code. - Query `limit` (integer): Rows per page, 1–100 (default 25). More than 50 costs 3 units. - Query `offset` (integer): Rows to skip (default 0). ### GET /v1/suppliers/{code} One supplier. Permissions: view_suppliers ### POST /v1/suppliers Add a supplier. The code is given automatically. Permissions: add_supplier, view_suppliers - Body `name` (string, required): The name. - Body `phone` (string): Mobile number. - Body `phone2` (string): A second mobile number. - Body `address` (string): Address. - Body `field` (string): Line of business. - Body `allow_similar` (boolean): See POST /v1/customers. ### PATCH /v1/suppliers/{code} Change a supplier. Only the fields sent change; an empty string clears a field. Permissions: edit_supplier, view_suppliers - Body `name` (string): Name. - Body `phone` (string): Phone. - Body `phone2` (string): Second phone. - Body `company` (string): Company. - Body `address` (string): Address. - Body `field` (string): Line of business. - Body `notes` (string): Notes. ### DELETE /v1/suppliers/{code} Delete a supplier. Refused (SUPPLIER_HAS_BILLS) once the supplier has any bill. Permissions: delete_supplier ### GET /v1/products Products (not deleted), newest first. Purchase cost only with view_purchase_prices. Permissions: view_warehouses - Query `search` (string): Part of the name. - Query `category` (string): A category code. - Query `barcode` (string): Exact product code / barcode. - Query `limit` (integer): Rows per page, 1–100 (default 25). More than 50 costs 3 units. - Query `offset` (integer): Rows to skip (default 0). ### GET /v1/products/{code} One product (every variant sharing the code). Permissions: view_warehouses ### GET /v1/products/{code}/stock Quantity of one product per warehouse. Permissions: view_warehouses ### POST /v1/products Register a new product (quantity comes with a purchase bill or a stock-take). The same name and specs twice is refused. Permissions: edit_warehouse - Body `name` (string, required): Product name. - Body `sale_price` (number, required): Retail price. - Body `wholesale_price` (number): Wholesale price. - Body `unit` (string): Unit (piece, box, kilo...). - Body `barcode` (string): Barcode; empty = given automatically. - Body `specs` (array): Specifications, e.g. [{"name":"Size","value":"1 L"}]. Items: {"name":"string","value":"string"} ### DELETE /v1/products/{code} Delete a product (soft delete, like the app: old bills and batches keep it). Permissions: edit_warehouse ### GET /v1/stock Stock batches (product, warehouse, quantity, expiry). Permissions: view_warehouses - Query `warehouse` (string): A warehouse code. - Query `product_code` (string): A product code. - Query `in_stock` (boolean): Only batches with quantity above zero. - Query `limit` (integer): Rows per page, 1–100 (default 25). More than 50 costs 3 units. - Query `offset` (integer): Rows to skip (default 0). ### GET /v1/sales-bills Sales bills, newest first (headers only). Permissions: view_sales - Query `customer` (string): A customer code. - Query `search` (string): Bill code, customer name or phone. - Query `from` (string): Only rows on or after this date (YYYY-MM-DD). - Query `to` (string): Only rows on or before this date (YYYY-MM-DD). - Query `limit` (integer): Rows per page, 1–100 (default 25). More than 50 costs 3 units. - Query `offset` (integer): Rows to skip (default 0). ### GET /v1/sales-bills/{code} One sales bill with its lines. Permissions: view_sales ### POST /v1/sales-bills Create a sales bill. Stock, price limits, selling-at-loss and the account's rules are checked exactly like the bill screen; the bill, its lines, the stock movement and the payment are saved together or not at all. Permissions: add_sales_bill - Body `branch` (string): The branch the operation belongs to (a code from GET /v1/branches). Optional when the token is limited to one branch. - Body `customer_code` (string, required): The customer (every bill needs one). - Body `warehouse_code` (string): The warehouse the goods leave; empty if the branch has one. - Body `sale_type` (string: retail|wholesale): Price list used when unit_price is 0. - Body `items` (array, required): 1–30 lines. Items: {"product_code":"string","quantity":"number","unit_price":"number (0 = the product's own price)"} - Body `payment` (string: cash|credit): cash = paid in full now; credit = the rest stays on the account. - Body `paid_amount` (number): Credit only: what is paid now (0 if nothing). - Body `discount` (number): A discount amount on the whole bill (0 if none). - Body `notes` (string): Notes saved with the bill. - Body `vault_code` (string): The vault the money goes into / comes out of (GET /v1/vaults). Empty when the branch has one vault or a payment method is used. - Body `payment_method_code` (string): A payment method (GET /v1/payment-methods) instead of a vault: InstaPay, a wallet... ### DELETE /v1/sales-bills/{code} Delete a whole sales bill (its lines, stock and payments go back). A single line can never be deleted; a bill with returns or a closed shipment is refused, like in the app. Permissions: delete_sales_bill ### GET /v1/purchase-bills Purchase (supply) bills, newest first. Permissions: view_procurement - Query `supplier` (string): A supplier code. - Query `search` (string): Bill code or supplier name. - Query `from` (string): Only rows on or after this date (YYYY-MM-DD). - Query `to` (string): Only rows on or before this date (YYYY-MM-DD). - Query `limit` (integer): Rows per page, 1–100 (default 25). More than 50 costs 3 units. - Query `offset` (integer): Rows to skip (default 0). ### GET /v1/purchase-bills/{code} One purchase bill with its lines. Permissions: view_procurement ### POST /v1/purchase-bills Create a purchase bill into one warehouse. A line with an empty product_code registers a new product. Permissions: add_purchase_bill - Body `branch` (string): The branch the operation belongs to (a code from GET /v1/branches). Optional when the token is limited to one branch. - Body `supplier_code` (string, required): The supplier. - Body `warehouse_code` (string): The warehouse the goods enter; empty if the branch has one. - Body `items` (array, required): 1–30 lines. Items: {"product_code":"string (empty = new product)","name":"string (new product)","quantity":"number","cost_price":"number","sale_price":"number (new product)","wholesale_price":"number","unit":"string","expiry_date":"YYYY-MM-DD"} - Body `payment` (string: cash|credit): cash = paid in full now; credit = the rest stays on the account. - Body `paid_amount` (number): Credit only: what is paid now (0 if nothing). - Body `discount` (number): A discount amount on the whole bill (0 if none). - Body `notes` (string): Notes saved with the bill. - Body `vault_code` (string): The vault the money goes into / comes out of (GET /v1/vaults). Empty when the branch has one vault or a payment method is used. - Body `payment_method_code` (string): A payment method (GET /v1/payment-methods) instead of a vault: InstaPay, a wallet... ### DELETE /v1/purchase-bills/{code} Delete a whole purchase bill. Refused when its goods were already sold, like in the app. Permissions: delete_purchase_bill ### GET /v1/payments Money collected from customers or paid to suppliers. Permissions: view_customers, view_suppliers - Query `account` (string, required: customer|supplier): Which side (required). - Query `code` (string): A customer / supplier code. - Query `from` (string): Only rows on or after this date (YYYY-MM-DD). - Query `to` (string): Only rows on or before this date (YYYY-MM-DD). - Query `limit` (integer): Rows per page, 1–100 (default 25). More than 50 costs 3 units. - Query `offset` (integer): Rows to skip (default 0). ### POST /v1/customer-payments Collect money from a customer (lowers what they owe). Permissions: collect_from_customer, view_customers - Body `branch` (string): The branch the operation belongs to (a code from GET /v1/branches). Optional when the token is limited to one branch. - Body `customer_code` (string, required): The customer. - Body `amount` (number, required): The amount. - Body `notes` (string): Notes. - Body `vault_code` (string): The vault the money goes into / comes out of (GET /v1/vaults). Empty when the branch has one vault or a payment method is used. - Body `payment_method_code` (string): A payment method (GET /v1/payment-methods) instead of a vault: InstaPay, a wallet... ### POST /v1/supplier-payments Pay money to a supplier (lowers what is owed to them). The vault or payment method must hold enough. Permissions: pay_supplier, view_suppliers - Body `branch` (string): The branch the operation belongs to (a code from GET /v1/branches). Optional when the token is limited to one branch. - Body `supplier_code` (string, required): The supplier. - Body `amount` (number, required): The amount. - Body `notes` (string): Notes. - Body `vault_code` (string): The vault the money goes into / comes out of (GET /v1/vaults). Empty when the branch has one vault or a payment method is used. - Body `payment_method_code` (string): A payment method (GET /v1/payment-methods) instead of a vault: InstaPay, a wallet... ### GET /v1/expenses Expenses, newest first. Permissions: view_expenses - Query `search` (string): Description or code. - Query `from` (string): Only rows on or after this date (YYYY-MM-DD). - Query `to` (string): Only rows on or before this date (YYYY-MM-DD). - Query `limit` (integer): Rows per page, 1–100 (default 25). More than 50 costs 3 units. - Query `offset` (integer): Rows to skip (default 0). ### POST /v1/expenses Record an expense paid from a vault or a payment method. Permissions: add_expense - Body `branch` (string): The branch the operation belongs to (a code from GET /v1/branches). Optional when the token is limited to one branch. - Body `description` (string, required): What it was for. - Body `amount` (number, required): The amount. - Body `category` (string: electricity|water|gas|internet_phone|rent|salaries|maintenance|transport|packaging|marketing|cleaning|other): Category. - Body `vault_code` (string): The vault the money goes into / comes out of (GET /v1/vaults). Empty when the branch has one vault or a payment method is used. - Body `payment_method_code` (string): A payment method (GET /v1/payment-methods) instead of a vault: InstaPay, a wallet... ### DELETE /v1/expenses/{code} Delete an expense (its vault movement goes with it). Permissions: delete_expense ### GET /v1/events What was created, changed or deleted, oldest first after a cursor — sync incrementally instead of re-reading everything. Only entities the token may read. - Query `after` (integer): Return events with an id greater than this (0 = from the oldest kept). - Query `type` (string): Filter, e.g. sales_bill or sales_bill.deleted. - Query `limit` (integer): 1–100 (default 50). ## Objects ### Error - error (object) ### Pagination - limit (integer) - offset (integer) - has_more (boolean) - next_offset (integer|null): Pass as offset for the next page; null on the last page. ### Me - token (object) - permissions (array): The permission keys this token holds. - branches (array|null): Branch codes the token may work in; null = all. - rate_limit (object) - api_version (string) ### Branch - code (string) - name (string) - address (string|null) - phone (string|null) - default_warehouse (string|null) - default_vault (string|null) ### Warehouse - code (string) - name (string) - branches (array) - default_branch (string|null) ### Vault - code (string) - name (string) - branch (string): Branch name. ### PaymentMethod - code (string) - name (string) - deferred (boolean): Money arrives later (e.g. a card settlement). ### Category - code (string) - name (string) - parent_code (string|null) ### Customer - code (string) - name (string) - phone (string|null) - phone2 (string|null) - email (string|null) - company (string|null) - address (string|null) - gender (string|null): male | female - notes (string|null) - branch (string|null) - blacklisted (boolean): Marked as not committed (غير ملتزم). - credit_limit (number|null) - balance (number|null): What the customer owes (positive) — null without permission to see balances. - net_balance (number|null): Balance netted with a linked supplier account. - created_by (string|null): Who created it: a user name, or "API · " when made through the API. - edited_by (string|null): Who last edited it (same form as created_by). ### Supplier - code (string) - name (string) - phone (string|null) - phone2 (string|null) - phone3 (string|null) - company (string|null) - address (string|null) - field (string|null): Line of business. - notes (string|null) - balance (number|null): What you owe the supplier — null without permission to see balances. - net_balance (number|null) - created_by (string|null): Who created it: a user name, or "API · " when made through the API. - edited_by (string|null): Who last edited it (same form as created_by). ### Product - code (string) - name (string) - specs (array): Specifications. - unit (string|null) - category_code (string|null) - retail_price (number|null) - wholesale_price (number|null) - compare_at_price (number|null): Price before discount. - min_price (number|null): Lowest price allowed on a bill. - max_price (number|null): Highest price allowed on a bill. - low_stock_alert (number|null) - variant_group (string|null): Products sharing it are variants of one item. - image (string|null) - description (string|null): HTML. - hidden (boolean) - created_by (string|null): Who created it: a user name, or "API · " when made through the API. - edited_by (string|null): Who last edited it (same form as created_by). ### StockRow - product_code (string) - name (string) - specs (array): Specifications. - warehouse (string): Warehouse code. - batch_code (string|null) - quantity (number) - expiry_date (string|null) - supply_date (string|null): ISO 8601 UTC. - unit_cost (number|null): Only with view_purchase_prices. ### SalesLine - product_code (string) - name (string) - specs (array): Specifications. - quantity (number|null) - unit_price (number|null): Price sold at. - list_price (number|null) - sale_type (string|null): retail | wholesale - gift (boolean): Given free. - returned_quantity (number|null) - warehouse (string|null) - notes (string|null) - unit_cost (number|null): Only with view_purchase_prices. ### SalesBill - code (string) - date (string|null): ISO 8601 UTC. - type (string): BILL, ORDER (sales order), RETURN... - customer_code (string|null) - customer_name (string|null) - branch (string|null): Branch code. - warehouse (string|null) - subtotal (number|null) - discount (number|null) - total (number|null) - paid (number|null) - remaining (number|null) - is_credit (boolean): On account (آجل). - returned (boolean) - return_of (string|null): For a return: the original bill. - sale_type (string|null) - sales_channel (string|null) - payment_method (string|null) - vault (string|null) - shipping (object|null) - store_order (string|null): Online-store order it came from. - notes (string|null) - cashier (string|null) - lines (array): Only on single-bill reads. - created_by (string|null): Who created it: a user name, or "API · " when made through the API. - edited_by (string|null): Who last edited it (same form as created_by). ### PurchaseLine - product_code (string) - name (string) - specs (array): Specifications. - quantity (number|null) - retail_price (number|null) - wholesale_price (number|null) - expiry_date (string|null) - batch_code (string|null) - returned_quantity (number|null) - unit_cost (number|null): Only with view_purchase_prices. ### PurchaseBill - code (string) - date (string|null): ISO 8601 UTC. - type (string) - supplier_code (string|null) - warehouse (string|null) - subtotal (number|null) - discount (number|null) - total (number|null) - paid (number|null) - is_credit (boolean) - returned (boolean) - return_of (string|null) - notes (string|null) - lines (array): Only on single-bill reads. - created_by (string|null): Who created it: a user name, or "API · " when made through the API. - edited_by (string|null): Who last edited it (same form as created_by). ### Payment - code (string) - date (string|null): ISO 8601 UTC. - account (string): customer | supplier - party_code (string) - amount (number) - bill_code (string|null): The bill it settled, if any. - branch (string|null) - notes (string|null) - created_by (string|null): Who created it: a user name, or "API · " when made through the API. - edited_by (string|null): Who last edited it (same form as created_by). ### Expense - code (string) - date (string|null): ISO 8601 UTC. - description (string) - amount (number) - category (string|null) - branch (string|null): Branch name. - created_by (string|null): Who created it: a user name, or "API · " when made through the API. - edited_by (string|null): Who last edited it (same form as created_by). ### Event - id (integer): Increasing. Use it as the cursor (after=) and to ignore repeats. - type (string): ., e.g. sales_bill.deleted - entity (string): customer, supplier, product, sales_bill, purchase_bill, payment, expense - code (string): The record code. Read the record itself for its current state. - source (string): app (someone in Prof), api (a token) or system (Prof itself: store sync, workers). - actor (string): The user, or "API · ". - occurred_at (string): ISO 8601 UTC. - deleted (object|null): Deletes only: the record as it was (same shape as the resource). ## Errors - 400 INVALID_JSON: The body is not a JSON object. - 400 INVALID_PARAMETER / INVALID_DATE / INVALID_CODE: A query value or path code is not valid (dates are YYYY-MM-DD). - 400 INVALID_IDEMPOTENCY_KEY: Idempotency-Key must be 8–100 characters of letters, digits, "-" or "_". - 401 MISSING_TOKEN: No "Authorization: Bearer " header. - 401 INVALID_TOKEN: Unknown token. - 401 TOKEN_EXPIRED: The token passed its expiry date. Extend it in Prof. - 401 TOKEN_REVOKED: Someone revoked the token in Prof. - 403 IP_NOT_ALLOWED: The token is limited to other IP addresses. - 403 FORBIDDEN: The token lacks a permission; details.missing_permission names it when known. - 403 BRANCH_ACCESS_DENIED: The token is limited to other branches. - 403 PLAN_NOT_PREMIUM: The account is not on a paid plan. - 403 API_DISABLED / DOMAIN_SUSPENDED: The API or the account is switched off. Contact support. - 404 NOT_FOUND: No such endpoint, or no such record (or not visible to this token). - 405 METHOD_NOT_ALLOWED: The path exists with another method. - 409 SIMILAR_RECORDS_EXIST: A customer/supplier with this phone (or name) exists; details.existing lists them. A phone can never be reused; for the same name with another phone send "allow_similar": true. - 409 IDEMPOTENCY_IN_PROGRESS: The first request with this key is still running. Retry in a moment. - 413 BODY_TOO_LARGE: Bodies are limited to 256 KB. - 422 VALIDATION_FAILED: The request breaks one of the account's rules (stock, prices, missing data...); message says which. - 422 INSUFFICIENT_FUNDS: The vault or payment method does not hold enough money. - 422 BRANCH_REQUIRED: Say which branch (the token works in more than one). - 422 IDEMPOTENCY_KEY_REUSED: The same key was used with a different request. - 422 : The same refusals the app gives, e.g. CUSTOMER_HAS_BILLS, SUPPLIER_HAS_BILLS, INSUFFICIENT_STOCK, BILL_HAS_RETURNS, SUPPLY_BILL_GOODS_SOLD. - 429 RATE_LIMITED: Over the per-minute budget. Wait Retry-After seconds. - 429 DAILY_LIMIT_REACHED: Over the per-day budget; resets at midnight Cairo time. - 429 TOKEN_PAUSED: Went over the limit repeatedly; paused for 15 minutes. - 500 SERVER_ERROR: Our fault. Safe to retry with the same Idempotency-Key. - 503 MAINTENANCE / API_UNAVAILABLE: Try again shortly (Retry-After).