Every company gets an id that never changes
Every company is keyed by a random co_ id. Why a name can't be a key, what a merge looks like on the wire, and the one line to add.
Every company profile is identified by an id like co_7Hk2p9Qx: co_
followed by eight letters and digits. It's the key of the Company
object, it's what
/v1/companies/{id} takes, and
company_id= / exclude_company_id= filter /v1/jobs by it.
The id is random: not derived from a name, a board or a website. That property is the point.
A name is a terrible key
A derived key is a promise that the thing it was derived from never changes. Company names fail that promise constantly, and in every direction:
- They change. A rebrand, an acquisition, a legal-name cleanup. A key built from the old name either changes with it, breaking every id you stored, or doesn't, and stops describing the company it names.
- They collide. There are a lot of companies called Apex. A key built from a name needs a tiebreaker, and the tiebreaker is usually whichever one we saw first, which is not a fact about either company.
- They're wrong at first. The first time we see an employer it's often a board token or a careers-site domain, not the company's real name. The key gets minted from the worst information we will ever have about it.
The last one matters most. Resolving postings to companies is ongoing work: we learn that a careers domain belongs to a company we already know, that two profiles are the same employer, that a board belongs to a parent rather than a subsidiary. Every one of those discoveries is good for the data, and under a derived key, every one of them is a key change you'd have to absorb.
A key derived from what we know changes when we learn something. A random key changes never.
What the id promises
| Property | What it means for you |
|---|---|
| Random | Not built from the name, the domain, or the board. You can't construct one: read it from a job or from /v1/companies. |
| Permanent | It doesn't change while the company exists. Store it as a foreign key. |
| Never reused | An id that stops naming a company never names a different one. |
| Present only on a profile | company.id is how you tell a full profile from the minimal fallback, which has no id. |
The last row is worth a second look. A job's company can be a full profile,
a four-field fallback built from the employer name the posting declared, or
null. id is the one field guaranteed on the first and impossible on the
second, so it's the test:
const isProfile = job.company?.id != null;A merge is a redirect
Random keys raise the obvious question: if we discover that co_A and co_B
are the same company, what happens to the one that goes away?
It keeps its id, and the id becomes a pointer.
Two profiles
co_A and co_B
Same employer
we merge them
co_B survives
jobs move to it
co_A answers 301
→ /v1/companies/co_B
Concretely:
/v1/companies/co_Aanswers301with aLocationpointing at the survivor. One hop, always to a company that exists.company_id=co_Aon/v1/jobsmatches the survivor's jobs. A saved search keyed on the old id keeps returning the right postings; it doesn't go quietly empty.exclude_company_id=co_Aexcludes the survivor, for the same reason. Jobs with no resolved company survive the exclusion.
So nothing you stored breaks when a merge happens. It just gets one redirect further from the truth than it needs to be.
The one line to add
Most HTTP clients follow a 301 without telling you. That's fine for reading
(you get the survivor's profile), but it means the stale id stays in your
database forever, and every lookup pays a hop. Notice the redirect and store
where it landed:
const res = await fetch(`https://api.hyperjobs.io/v1/companies/${id}`, {
headers: { Authorization: `Bearer ${process.env.HYPERJOBS_KEY}` },
});
const company = await res.json();
if (res.redirected) {
// The id we held was merged into another company. company.id is the survivor's.
await db.companies.repoint(id, company.id);
}With curl, pass -L to follow it, or leave it off and read the Location
header yourself, which is the cheaper way to sweep a list of stored ids for
merges: a 301 bills no jobs.
Don't parse the id
There's nothing in it to read: the eight characters are random, so they say nothing about the company, its age, or its source. Store it as text and compare it as an opaque string.
Building on it
Key your companies table on id
Store
company.idas the primary key, as text. Names, domains and LinkedIn pages are attributes that can change; the id is the one column that won't.Filter by id, not by name
company_id=andexclude_company_id=on/v1/jobstake a comma list. A saved search keyed on ids keeps matching through a rebrand.Detect the fallback with id
job.company?.id != nullis a profile. A job without one carries the minimal shape: a name and little else, so don't upsert it into your companies table as if it were a profile.Handle the 301
Follow it, and repoint the stored id when you see one. It's the only part that needs code of its own, and it's the part that keeps your data clean for good.
The ids you store keep working for as long as the company does, whatever we find out about it next.
Keep reading
Why every job carries its company
Most jobs APIs hand you an employer name and leave you to resolve it. Here is what changes when the company object is already attached.
6 min read
One field for where a job is done
Where a job is done is one field, work_arrangement, with four answers. How to filter on it, what null means, and how remote_location differs.
3 min read
The same role posted twice is one job
A role mirrored to Greenhouse and LinkedIn is one posting, not two. What deduplication has to decide, and what the API lets you see.
7 min read