Skip to content

Ask the CRM about its API credits, then say what is known

POST
/orgs/{org}/connectors/{id}/credits/check
curl --request POST \
--url https://api.sloose.com/orgs/org_9f3c/connectors/cnn_9f2a/credits/check \
--header 'Authorization: Bearer <token>'

What GET …/credits answers, after asking the CRM once where it may be asked — for a page’s “Check again”, since the read alone can only repeat a count no call has refreshed. Zoho CRM connections only; a connection of any other kind, or one that cannot call (disconnected, or holding no working grant), is answered with what is known and nothing is asked.

The one call is the CRM’s organisation record (GET /org), sent with the connection’s own grant through the gate every call to that CRM passes. It names no module and reads one record; Zoho’s published table charges it one API credit, and Zoho’s own dashboard counts a call it refuses as well. What the answer says of the licence is kept, so an edition changed since the last read shows in allowance and edition too.

It is not sent every time:

  • while the CRM’s day is known spent (spent), Sloose lets one call a minute through to that CRM, whoever makes it — a call somebody made, never a read Sloose makes for its own upkeep; a check inside that minute sends nothing. The call that goes is the one that can clear spent: Zoho doing it as asked does, and a refusal or a failure does not;
  • otherwise at most once in 30 seconds a connection; a check sooner sends nothing.

Whether one was sent is asked, and whether the CRM answered it answered (#2140): as asked, or with the refusal that says its day is spent. A call that went and met nothing it could read — a timeout, a failure, a grant the CRM no longer honours — is sent and not answered, and credits then says only what was known before. Where nothing was sent, notAsked says why. The answer is 200 either way, and the connection’s own page says what state it is in. Zoho names no time at which credits return, and nothing here does.

org
required

The organisation id the session was issued for. A token for one organisation can never read another.

string
Example
org_9f3c

The organisation id the session was issued for. A token for one organisation can never read another.

id
required

The connector id, from the list.

string
Example
cnn_9f2a

The connector id, from the list.

What is known, after the CRM was asked where it could be.

Media typeapplication/json
object
credits
required
object
remaining
required

The credits the CRM last said were left (X-API-CREDITS-REMAINING), or null: Zoho sends it on any call once half the day is spent and not before, and a count more than a day old is none.

number | null
remainingAt
required

When the CRM said so, any organisation’s call counted.

string | null
allowance
required

The CRM’s day, from its licence by Zoho’s published table — or null where its edition or licence count is not known. Add-on credits and other apps’ use of the pool cannot be seen.

number | null
allowanceAtLeast
required

Whether allowance is a floor: the figure Zoho publishes for the edition, which its own dashboard has shown a CRM to exceed (the Free edition). False for a figure the table gives outright, and where there is none.

boolean
edition
required

The edition the licence was read as, where it was recognised.

string | null
spent
required

Whether the CRM’s API allowance is known to be spent now: Zoho refused a call because the last 24 hours’ credits are used up, and no call has been answered since. While it is, Sloose refuses this CRM’s calls before sending them, letting one a minute through to ask again; the first of those Zoho does as asked makes this false, and one that fails or is refused does not. Zoho names no time at which credits return.

boolean
spentAt
required

When Sloose first heard the allowance was spent, or null while it is not.

string | null
asked
required

Whether a call was sent to the CRM for this check. False inside the minute a known spent day allows one call in, inside the 30 seconds between checks, and for a connection that cannot be asked.

boolean
answered
required

Whether the CRM answered the call it was sent: as asked, or refusing it because its day is spent. False where nothing was sent, and where the call failed, timed out or was refused for its grant — the CRM said nothing of its credits then.

boolean
notAsked
required

Why nothing was sent, or null where a call was: cannot, the connection cannot be asked at all (another kind, disconnected, or holding no working grant), so no later check will ask either until it is reconnected; too_soon, inside the minute a spent day allows one call in, or the 30 seconds between checks.

string | null
Allowed values: cannot too_soon
Example
{
"notAsked": "cannot"
}

No bearer, or one that no longer resolves: a session that is unknown or expired (code: AUTH_REQUIRED), or an API token that was revoked or expired (TOKEN_REVOKED, TOKEN_EXPIRED), whose organisation is gone (ORG_NOT_FOUND) or whose member or user row is (MEMBERSHIP_GONE).

Media typeapplication/json

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
Examplegenerated
{
"error": "example",
"code": "example"
}

The bearer’s role is too low (code: ROLE_REQUIRED), or it was issued for a different organisation; the organisation has been closed (code: ORG_CLOSED, either kind of bearer); the person is banned (code: BANNED, a session); or it is a session that is signed in but in no organisation (code: NO_ORG): one that never joined one, or whose person was taken out of the one it was in, or left it. Signing in again changes nothing for NO_ORG; choosing or making an organisation does.

Media typeapplication/json

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
Examplegenerated
{
"error": "example",
"code": "example"
}

No such connector, or it is not visible to this session.

Media typeapplication/json

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
Examplegenerated
{
"error": "example",
"code": "example"
}

The restore switch is on (code: MAINTENANCE): every route but /health and /robots.txt is refused before anything is read, except the operator’s own POST /staff/people/{id}/delete with the ADMIN_TOKEN. Sloose is down for maintenance. Please try again in a few minutes.

Media typeapplication/json
object
error
required
string
code
required
string
Allowed value: MAINTENANCE
Example
{
"code": "MAINTENANCE"
}
Retry-After
integer

Seconds until asking again is worth it (300 while the switch is on).

Report a problem with this page

sloose.com