Skip to content

Tell EdgeKit which billing accounts are companies

Before EdgeKit gives a billing account a grant, it needs to know who holds the account. By default, every billing account is one person: the user with the account’s email address. That is right when you sell only to individuals.

When you sell to companies through the same billing accounts, a company’s account carries its billing contact’s email address. If EdgeKit reads that account as a person, the billing contact gets the company’s whole purchase as their own access. A subject resolver stops this. It is an endpoint you host. EdgeKit asks it whether a Recurly account code is a person or a company, and acts on the answer.

EdgeKit asks about a Recurly account when all of these are true:

  • One of its user subscriptions is about to get its first grant. See How access follows your billing provider.
  • The account is not yet linked to a user or a user organization.
  • EdgeKit does not know the account’s code yet. A code that is a user’s id, a user organization’s id, or the external id of either links the account without asking.

EdgeKit never asks about a Stripe billing account, which has no account code. Once an account is linked, EdgeKit does not ask about it again.

POST <your resolver URL>
Authorization: Bearer <your resolver token>
Content-Type: application/json
{ "codes": ["A123"] }

codes holds Recurly account codes. EdgeKit sends one code per request today. Answer every code in the list, as a later request can carry several.

Answer 200 with a JSON body:

{
"subjects": [
{ "code": "A123", "type": "user" },
{
"code": "A456",
"type": "org",
"name": "Acme Ltd",
"domains": ["acme.example"]
},
{ "code": "A789", "type": "unknown" }
]
}
  • type: user for a person, org for a company, unknown when your system cannot tell. Any other value reads as unknown.
  • name and domains: optional, for org. The company’s name, and the email domains its employees sign in with.
  • A code you leave out reads as unknown. A code EdgeKit did not ask about is ignored.

EdgeKit checks the whole body before it uses any of it, and rejects all of it when it is not JSON, has no subjects list, has an entry with no code or a field of the wrong type, or answers one code twice.

Answer user only for an account you know is a person. If you are unsure, answer unknown: EdgeKit never guesses for you.

Answer What EdgeKit does
user Links the account to the user with its email address, or creates that user with the address unverified, then creates the grant. The code becomes the user’s external id, unless the user already has one.
org Links the account to the user organization whose external id is the code, or creates one. No user and no grant. See What an org answer creates.
unknown No user and no grant. EdgeKit records the account as unresolved, with reason subject-unresolved, and asks again the next time the user subscription syncs. The record is closed once the account is linked.

EdgeKit creates one user organization per code, with the code as its external id, and links every billing account with that code to it. The account and the organization are linked in one step: if any part fails, none of it is kept and EdgeKit retries.

  • Name: your name, else the Recurly account’s company, else its display name. EdgeKit trims it and keeps the first 200 characters.
  • Slug: made from the name. When another user organization already has it, EdgeKit adds a number: acme, then acme-2.
  • Domains: each of your domains becomes an auto-join domain of the organization, in lower case. EdgeKit drops a value that is not a hostname, and a public email provider such as gmail.com. A domain that another user organization already has stays with that organization: EdgeKit records the account with reason domain-claimed, and applies the rest of the answer.

The organization has no members when it is created. See User organizations for how a domain adds them.

A request that takes longer than 10 seconds, a status other than 2xx, or a body EdgeKit cannot use is an error, never an answer. EdgeKit writes nothing for that account and retries later. It never falls back to reading the account as a person.

The first run over your existing user subscriptions asks about each unlinked account, at about 10 requests a second. 50,000 accounts take about 80 minutes. After that, EdgeKit asks about an account only when one of its user subscriptions syncs and the account is still unlinked.

EdgeKit sets up the resolver for your organization. Give EdgeKit your endpoint’s URL and a token for it. EdgeKit holds the token and sends it as the bearer on every request. Serve the endpoint over HTTPS. With no resolver set up, EdgeKit reads every billing account as a person.

edgekit.ai