Companies

A company's details, categories summary, tax years, summary figures and activity.

MethodPathSummary
GET/api/meWho you are: the signed-in person and what they can do here
GET/api/companies/:companyIdGet a company
PUT/api/companies/:companyIdUpdate a company
GET/api/companies/:companyId/tax-yearsTax years with data
GET/api/companies/:companyId/summaryA tax year's figures
GET/api/companies/:companyId/activityRecent activity

#Who you are: the signed-in person and what they can do here

GET/api/me
Address
https://<your-org>.brambleit.cloud/simplebooks/api/me
Requires
Signed-in browser session (the sso_session / session_id cookies from Bramble sign-in).
Licence: SimpleBooks.

Response 200

FieldTypeDescription
userobject
user.idinteger
user.namestring
user.first_namestring
user.emailstring
companiesarray of any
Example response
JSON
{
  "user": {
    "id": 42,
    "name": "Example name",
    "first_name": "Alex",
    "email": "alex@example.com"
  },
  "companies": []
}

Example request

JavaScript
// From a page served by Bramble (uses the signed-in session)
const res = await fetch('/simplebooks/api/me', {
  method: 'GET',
  credentials: 'include',
});
const data = await res.json();

#Get a company

GET/api/companies/:companyId
Address
https://<your-org>.brambleit.cloud/simplebooks/api/companies/:companyId
Requires
Signed-in browser session (the sso_session / session_id cookies from Bramble sign-in).
Licence: SimpleBooks.

Path parameters

NameTypeDescription
companyIdrequiredinteger

Response 200

FieldTypeDescription
companyobject
company.idinteger
company.namestring
company.trading_namestring, or null
company.business_typestring: "sole_trader" | "partnership" | "limited"
company.owner_namestring, or null
company.utrstring, or null
company.vat_numberstring, or null
company.addressstring, or null
company.emailstring, or null
company.phonestring, or null
company.year_endstring: "mar31" | "apr5"
company.roleany
company.modulesarray of any
categoriesarray of object
categories[].idinteger
categories[].namestring
categories[].tax_keystring, or null
categories[].iconstring
categories[].sortinteger
categories[].archivedboolean
categories[].usesinteger
tax_keysarray of object
tax_keys[].keystring
tax_keys[].labelstring
current_tax_yearany
permissionsobject
permissions.see_allany
permissions.reportsarray of any
permissions.manage_companyany
permissions.manage_categoriesboolean
permissions.add_receiptsboolean
permissions.invoicesboolean
permissions.manage_invoicesboolean
permissions.taxboolean
permissions.incomeboolean
permissions.manage_incomeboolean
Example response
JSON
{
  "company": {
    "id": 42,
    "name": "Example name",
    "trading_name": "Example trading name",
    "business_type": "sole_trader",
    "owner_name": "Example owner name",
    "utr": "string",
    "vat_number": "string",
    "address": "string",
    "email": "alex@example.com",
    "phone": "string",
    "year_end": "mar31",
    "role": null,
    "modules": []
  },
  "categories": [
    {
      "id": 42,
      "name": "Example name",
      "tax_key": "…",
      "icon": "string",
      "sort": 1,
      "archived": false,
      "uses": 1
    }
  ],
  "tax_keys": [
    {
      "key": "…",
      "label": "Example label"
    }
  ],
  "current_tax_year": null,
  "permissions": {
    "see_all": null,
    "reports": [],
    "manage_company": null,
    "manage_categories": false,
    "add_receipts": false,
    "invoices": false,
    "manage_invoices": false,
    "tax": false,
    "income": false,
    "manage_income": false
  }
}

Example request

JavaScript
// From a page served by Bramble (uses the signed-in session)
const res = await fetch('/simplebooks/api/companies/1', {
  method: 'GET',
  credentials: 'include',
});
const data = await res.json();

#Update a company

PUT/api/companies/:companyId
Address
https://<your-org>.brambleit.cloud/simplebooks/api/companies/:companyId
Requires
Signed-in browser session (the sso_session / session_id cookies from Bramble sign-in).
Licence: SimpleBooks.

Path parameters

NameTypeDescription
companyIdrequiredinteger

Request body JSON

NameTypeDescription
kany

Response 200

FieldTypeDescription
okboolean
Example response
JSON
{
  "ok": true
}

Errors

StatusMessage
400The company needs a name
400A UTR is 10 digits
400Unknown year end

Example request

JavaScript
// From a page served by Bramble (uses the signed-in session)
const res = await fetch('/simplebooks/api/companies/1', {
  method: 'PUT',
  credentials: 'include',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({"k":"…"}),
});
const data = await res.json();

#Tax years with data

GET/api/companies/:companyId/tax-years
Address
https://<your-org>.brambleit.cloud/simplebooks/api/companies/:companyId/tax-years
Requires
Signed-in browser session (the sso_session / session_id cookies from Bramble sign-in).
Licence: SimpleBooks.

Path parameters

NameTypeDescription
companyIdrequiredinteger

Response 200

FieldTypeDescription
currentany
yearsarray of any
Example response
JSON
{
  "current": null,
  "years": []
}

Example request

JavaScript
// From a page served by Bramble (uses the signed-in session)
const res = await fetch('/simplebooks/api/companies/1/tax-years', {
  method: 'GET',
  credentials: 'include',
});
const data = await res.json();

#A tax year's figures

GET/api/companies/:companyId/summary
Address
https://<your-org>.brambleit.cloud/simplebooks/api/companies/:companyId/summary
Requires
Signed-in browser session (the sso_session / session_id cookies from Bramble sign-in).
Licence: SimpleBooks.

Path parameters

NameTypeDescription
companyIdrequiredinteger

Query parameters

NameTypeDescription
tax_yearany

Response 200

FieldTypeDescription
tax_yearany
rangeany
totalsobject
totals.receiptsinteger
totals.spentany
totals.claimableany
totals.vatany
totals.to_reviewnumber
totals.undatedinteger
by_categoryarray of object
by_category[].category_idinteger, or null
by_category[].namestring
by_category[].iconstring
by_category[].tax_keystring, or null
by_category[].ninteger
by_category[].spentany
by_category[].claimableany
by_montharray of object
by_month[].monthstring
by_month[].ninteger
by_month[].spentany
by_tax_keystring
Example response
JSON
{
  "tax_year": null,
  "range": null,
  "totals": {
    "receipts": 1,
    "spent": null,
    "claimable": null,
    "vat": null,
    "to_review": 12.5,
    "undated": 1
  },
  "by_category": [
    {
      "category_id": 7,
      "name": "Example name",
      "icon": "string",
      "tax_key": "…",
      "n": 3,
      "spent": null,
      "claimable": null
    }
  ],
  "by_month": [
    {
      "month": "string",
      "n": 3,
      "spent": null
    }
  ],
  "by_tax_key": "…"
}

Example request

JavaScript
// From a page served by Bramble (uses the signed-in session)
const res = await fetch('/simplebooks/api/companies/1/summary', {
  method: 'GET',
  credentials: 'include',
});
const data = await res.json();

#Recent activity

GET/api/companies/:companyId/activity
Address
https://<your-org>.brambleit.cloud/simplebooks/api/companies/:companyId/activity
Requires
Signed-in browser session (the sso_session / session_id cookies from Bramble sign-in).
Licence: SimpleBooks.

Path parameters

NameTypeDescription
companyIdrequiredinteger

Query parameters

NameTypeDescription
limitnumber

Response 200

FieldTypeDescription
activityarray of any
Example response
JSON
{
  "activity": []
}

Example request

JavaScript
// From a page served by Bramble (uses the signed-in session)
const res = await fetch('/simplebooks/api/companies/1/activity', {
  method: 'GET',
  credentials: 'include',
});
const data = await res.json();