{
    "info": {
        "name": "ZivoBooks API",
        "description": "Set keyId and secret in the collection variables, run \"Sign in\" once, then call anything. Tokens last an hour. Docs: https://www.zivobooks.com.suncloudsystems.co.za/developers/docs",
        "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
    },
    "auth": {
        "type": "bearer",
        "bearer": [
            {
                "key": "token",
                "value": "{{token}}",
                "type": "string"
            }
        ]
    },
    "variable": [
        {
            "key": "baseUrl",
            "value": "https://zivobooks.com"
        },
        {
            "key": "keyId",
            "value": "zbk_test_…"
        },
        {
            "key": "secret",
            "value": "zb_test_…"
        },
        {
            "key": "token",
            "value": ""
        }
    ],
    "item": [
        {
            "name": "Authentication",
            "item": [
                {
                    "name": "Sign in",
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "if (pm.response.code === 201) { pm.collectionVariables.set(\"token\", pm.response.json().access_token); }"
                                ]
                            }
                        }
                    ],
                    "request": {
                        "method": "POST",
                        "description": "Exchanges a key ID and secret for a session token that lasts one hour. Send the credentials in the JSON body (or as HTTP Basic, key ID as the username). Limited to 10 attempts a minute per IP address.",
                        "auth": {
                            "type": "noauth"
                        },
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"key_id\": \"{{keyId}}\",\n    \"secret\": \"{{secret}}\"\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        },
                        "url": {
                            "raw": "{{baseUrl}}/api/v1/auth/token",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "auth",
                                "token"
                            ]
                        }
                    }
                },
                {
                    "name": "Sign out",
                    "request": {
                        "method": "DELETE",
                        "description": "Ends the current session token straight away. Optional: tokens expire on their own after an hour.",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-Zivobooks-Key",
                                "value": "{{keyId}}"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/api/v1/auth/token",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "auth",
                                "token"
                            ]
                        }
                    }
                },
                {
                    "name": "Check a session",
                    "request": {
                        "method": "GET",
                        "description": "Confirms the session works, whether it is test or live, which business it belongs to and when it expires. Needs no scope.",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-Zivobooks-Key",
                                "value": "{{keyId}}"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/api/ping",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "api",
                                "ping"
                            ]
                        }
                    }
                }
            ]
        },
        {
            "name": "Customers",
            "item": [
                {
                    "name": "List customers",
                    "request": {
                        "method": "GET",
                        "description": "Customers in ID order, oldest first.",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-Zivobooks-Key",
                                "value": "{{keyId}}"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/api/v1/customers",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "customers"
                            ]
                        }
                    }
                },
                {
                    "name": "Create a customer",
                    "request": {
                        "method": "POST",
                        "description": "Adds a customer; the business’s next customer code is assigned. Send an Idempotency-Key header so a retry never creates a duplicate.",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-Zivobooks-Key",
                                "value": "{{keyId}}"
                            },
                            {
                                "key": "Idempotency-Key",
                                "value": "{{$guid}}"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"name\": \"Chikomo Builders\",\n    \"email\": \"accounts@chikomo.co.zw\",\n    \"phone\": \"+263 77 123 4567\",\n    \"address\": {\n        \"line1\": \"14 Samora Machel Ave\",\n        \"city\": \"Harare\"\n    }\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        },
                        "url": {
                            "raw": "{{baseUrl}}/api/v1/customers",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "customers"
                            ]
                        }
                    }
                },
                {
                    "name": "Get a customer",
                    "request": {
                        "method": "GET",
                        "description": "One customer by ID.",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-Zivobooks-Key",
                                "value": "{{keyId}}"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/api/v1/customers/:id",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "customers",
                                ":id"
                            ],
                            "variable": [
                                {
                                    "key": "id",
                                    "value": "1"
                                }
                            ]
                        }
                    }
                }
            ]
        },
        {
            "name": "Invoices",
            "item": [
                {
                    "name": "List invoices",
                    "request": {
                        "method": "GET",
                        "description": "Invoices in ID order, without their lines. Amounts are strings in the invoice’s own currency, so no precision is lost.",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-Zivobooks-Key",
                                "value": "{{keyId}}"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/api/v1/invoices",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "invoices"
                            ]
                        }
                    }
                },
                {
                    "name": "Create a draft invoice",
                    "request": {
                        "method": "POST",
                        "description": "Creates a draft invoice in the business’s base currency, numbered in its own sequence. Lines that name a product take its description, price and tax category unless you send them. Someone in the business reviews and sends the draft. Send an Idempotency-Key header.",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-Zivobooks-Key",
                                "value": "{{keyId}}"
                            },
                            {
                                "key": "Idempotency-Key",
                                "value": "{{$guid}}"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"customer_id\": 42,\n    \"issue_date\": \"2026-10-03\",\n    \"items\": [\n        {\n            \"product_id\": 7,\n            \"quantity\": 1\n        },\n        {\n            \"description\": \"Call-out fee\",\n            \"quantity\": 1,\n            \"unit_price\": \"25.00\"\n        }\n    ]\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        },
                        "url": {
                            "raw": "{{baseUrl}}/api/v1/invoices",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "invoices"
                            ]
                        }
                    }
                },
                {
                    "name": "Get an invoice",
                    "request": {
                        "method": "GET",
                        "description": "One invoice with its lines and the link the customer uses to view and pay it.",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-Zivobooks-Key",
                                "value": "{{keyId}}"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/api/v1/invoices/:id",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "invoices",
                                ":id"
                            ],
                            "variable": [
                                {
                                    "key": "id",
                                    "value": "1"
                                }
                            ]
                        }
                    }
                }
            ]
        },
        {
            "name": "Quotes",
            "item": [
                {
                    "name": "List quotes",
                    "request": {
                        "method": "GET",
                        "description": "Quotes in ID order.",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-Zivobooks-Key",
                                "value": "{{keyId}}"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/api/v1/quotes",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "quotes"
                            ]
                        }
                    }
                },
                {
                    "name": "Get a quote",
                    "request": {
                        "method": "GET",
                        "description": "One quote by ID.",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-Zivobooks-Key",
                                "value": "{{keyId}}"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/api/v1/quotes/:id",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "quotes",
                                ":id"
                            ],
                            "variable": [
                                {
                                    "key": "id",
                                    "value": "1"
                                }
                            ]
                        }
                    }
                }
            ]
        },
        {
            "name": "Payments",
            "item": [
                {
                    "name": "List payments",
                    "request": {
                        "method": "GET",
                        "description": "Customer payments in ID order, with the invoices each one paid.",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-Zivobooks-Key",
                                "value": "{{keyId}}"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/api/v1/payments",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "payments"
                            ]
                        }
                    }
                },
                {
                    "name": "Get a payment",
                    "request": {
                        "method": "GET",
                        "description": "One payment by ID.",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-Zivobooks-Key",
                                "value": "{{keyId}}"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/api/v1/payments/:id",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "payments",
                                ":id"
                            ],
                            "variable": [
                                {
                                    "key": "id",
                                    "value": "1"
                                }
                            ]
                        }
                    }
                }
            ]
        },
        {
            "name": "Products",
            "item": [
                {
                    "name": "List products",
                    "request": {
                        "method": "GET",
                        "description": "Products and services in ID order. Tracked products include a stock object with the quantity on hand in total and per branch; services and untracked products have stock: null. A stock movement counts as a change, so updated_since picks up stock changes.",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-Zivobooks-Key",
                                "value": "{{keyId}}"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/api/v1/products",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "products"
                            ]
                        }
                    }
                },
                {
                    "name": "Get a product",
                    "request": {
                        "method": "GET",
                        "description": "One product or service by ID, with stock on hand per branch when it’s tracked.",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-Zivobooks-Key",
                                "value": "{{keyId}}"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/api/v1/products/:id",
                            "host": [
                                "{{baseUrl}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "products",
                                ":id"
                            ],
                            "variable": [
                                {
                                    "key": "id",
                                    "value": "1"
                                }
                            ]
                        }
                    }
                }
            ]
        }
    ]
}