Colorado Secretary of State (United States)
reference Facts, options, APIs
On this page
- Open data, not the live register
- Settings
- Vocabulary and Properties
- Request and response
- Properties added by the enricher
- How the script handles input and errors
- Testing the enricher
- Limitations
- Process script
This example looks up an organization’s Colorado entity ID in the business entity register of the Colorado Secretary of State (Colorado Department of State). It uses the extract that the Department publishes on the Colorado Information Marketplace (dataset 4ykn-tg5h, Business Entities in Colorado), which covers corporations, LLCs, partnerships, nonprofits and other entities registered since 1864, whatever their current status. For each golden record it stores the entity name, status, entity type, jurisdiction of formation, formation date, principal and mailing addresses, and the registered agent. No API key is needed.
Enricher version: V2
API key: not needed (an optional data.colorado.gov app token raises the rate limit)
Open data, not the live register
The dataset is a copy of the Secretary of State’s business register that the portal refreshes daily (its metadata says Every day after midnight). It isn’t a live query of the register, so a filing made today appears the next day. For the current state of an entity, search the business database on the Secretary of State’s business pages.
To set up the enricher, see Add REST API enricher, then use the settings and script on this page.
Settings
-
Accepted Business Domain –
/Organization, or the business domain that holds your companies. -
Version – V2 (recommended).
-
API Key – leave empty, or enter a data.colorado.gov app token. Without a token, data.colorado.gov limits how many requests it accepts from one address; with one, the limit is much higher. To get a token, sign in to data.colorado.gov and create an app token in your developer settings (see Socrata app tokens). The script sends it in the
X-App-Tokenheader. -
Filters – we recommend a rule that only accepts golden records where
organization.coloradoEntityIdhas a value. Otherwise, every record without an entity ID is listed on the enricher’s Logs tab as having returned no results.
Vocabulary and Properties
organization.coloradoEntityId
organization.coloradoEntityId holds the Colorado Secretary of State entity ID (also called the ID number), for example 20031315478. If your data uses another vocabulary key, change this field and the ENTITY_ID_KEY value at the top of the script.
Request and response
Base URL: https://data.colorado.gov/resource
Endpoint: GET /4ykn-tg5h.json?entityid={entityId}
Authentication: none; optional app token in the X-App-Token header
Rate limits: requests without an app token are throttled per IP address; requests with one aren’t, unless they are abusive (see Socrata app tokens). Each request takes about 1 second.
The script sends one request per golden record:
GET https://data.colorado.gov/resource/4ykn-tg5h.json?entityid=20031315478
Accept: application/json
Response (one row; the entity ID is unique):
[
{
"entityid": "20031315478",
"entityname": "Molson Coors Beverage Company",
"principaladdress1": "320 South Canal Street",
"principaladdress2": "36th Floor",
"principalcity": "Chicago",
"principalstate": "IL",
"principalzipcode": "60606",
"principalcountry": "US",
"mailingaddress1": "PO Box 4030",
"mailingaddress2": "Bc555",
"mailingcity": "Golden",
"mailingstate": "CO",
"mailingzipcode": "80402",
"mailingcountry": "US",
"entitystatus": "Good Standing",
"jurisdictonofformation": "DE",
"entitytype": "FPC",
"agentorganizationname": "Incorporating Services, Ltd.",
"agentprincipaladdress1": "360 Acoma Street",
"agentprincipaladdress2": "Unit 118",
"agentprincipalcity": "Denver",
"agentprincipalstate": "CO",
"agentprincipalzipcode": "80223",
"agentprincipalcountry": "US",
"entityformdate": "2003-10-03T00:00:00.000"
}
]
An empty array ([]) means that the entity ID isn’t in the dataset. Fields without a value are left out of the row.
Properties added by the enricher
| Property | Response field | Example |
|---|---|---|
colorado.entityId | entityid | 20031315478 |
colorado.name | entityname | Molson Coors Beverage Company |
colorado.status | entitystatus | Good Standing |
colorado.entityType | entitytype (Secretary of State abbreviation) | FPC |
colorado.entityTypeDescription | what the entitytype abbreviation means, from the Secretary of State’s list of abbreviations | Foreign profit corporation |
colorado.jurisdiction | jurisdictonofformation (spelled this way in the dataset) | DE |
colorado.formationDate | entityformdate, as YYYY-MM-DD | 2003-10-03 |
colorado.principalAddress | principaladdress1, principaladdress2, principalcity, principalstate, principalzipcode, principalcountry, on one line | 320 South Canal Street, 36th Floor, Chicago, IL 60606, US |
colorado.principalCity | principalcity | Chicago |
colorado.principalState | principalstate | IL |
colorado.principalPostalCode | principalzipcode | 60606 |
colorado.principalCountry | principalcountry | US |
colorado.mailingAddress | mailingaddress1, mailingaddress2, mailingcity, mailingstate, mailingzipcode, mailingcountry, on one line | PO Box 4030, Bc555, Golden, CO 80402, US |
colorado.registeredAgent | agentorganizationname, or agentfirstname, agentmiddlename, agentlastname and agentsuffix when the agent is a person | Incorporating Services, Ltd. |
colorado.registeredAgentAddress | agentprincipaladdress1, agentprincipaladdress2, agentprincipalcity, agentprincipalstate, agentprincipalzipcode, agentprincipalcountry, on one line | 360 Acoma Street, Unit 118, Denver, CO 80223, US |
A property is added only when the dataset has a value for it. Entity types with the suffix -PBC (for example DPC-PBC) are public benefit corporations; their description ends with (public benefit). Abbreviations that aren’t on the Secretary of State’s list (such as CS, DLCA, FO, GP or UNA) are stored in colorado.entityType without a description.
If the enricher has a Preview tab, the results appear there first. To add them to golden records, go to the Map tab, select Map Data, and choose Auto Mapping. Select the business domain, enter a new vocabulary named Colorado with the key prefix colorado, and then create the mapping. Auto mapping also uses name as the golden record name, so remove that from the mapping if you want to keep your existing names. Then process the data on the Process tab. If the enricher has no Preview tab, the properties are added to the golden record as soon as it is enriched.
How the script handles input and errors
-
Spaces, dots, dashes and leading zeros are removed, so
2003-1315478is looked up as20031315478. The ID must then have 10 or 11 digits. Golden records without a valid ID are skipped without calling the API. -
The dataset includes entities of every status, so a dissolved, withdrawn or delinquent entity is added with its status, for example
colorado.status=Voluntarily Dissolved. -
If the entity ID isn’t in the dataset, the request is rejected, or the API returns an error, the script logs the reason and adds nothing, and nothing is cached.
-
If you entered an app token and data.colorado.gov rejects it, the script throws an error that says so, and the golden record fails.
-
If data.colorado.gov limits the requests (HTTP 429), the script throws an error that makes the enricher try the golden record again later. Enter an app token if this happens often.
-
Successful results are cached for 24 hours per entity ID. To change this, edit
CACHE_MILLISECONDSin the script.
Testing the enricher
-
Test connection checks only that the script runs. It doesn’t call the API.
-
To try the setup, create a golden record with
organization.coloradoEntityIdset to20031315478(Molson Coors Beverage Company) or20021056790(Newmont Corporation).
Limitations
-
The dataset is refreshed daily, not a live query of the register (see Open data, not the live register).
-
Lookups by name aren’t supported.
-
Old entities’ names can include their dissolution, for example
DENVER UNION CORPROATION, Dissolved January 17, 1983, as they do in the register. -
Trade names, filing history and officers aren’t added. Trade names and transaction history are separate datasets on data.colorado.gov (
u7sb-g482andcasm-dbbj).
Process script
// REST API enricher (V2) - Colorado business entity lookup
//
// Looks up a golden record's Colorado entity ID in the business entity register of the Colorado
// Secretary of State (Colorado Department of State, CDOS), using the extract that is published on
// the Colorado Information Marketplace (https://data.colorado.gov/, dataset 4ykn-tg5h, "Business
// Entities in Colorado"), and adds the result to the golden record as colorado.* properties:
//
// colorado.entityId entity ID that was looked up
// colorado.name entity name
// colorado.status entity status, for example Good Standing, Delinquent or Voluntarily Dissolved
// colorado.entityType entity type code, for example DLLC or FPC
// colorado.entityTypeDescription what that code means, for example Domestic limited liability company
// colorado.jurisdiction jurisdiction of formation, for example CO or DE
// colorado.formationDate date the entity was formed or registered in Colorado (YYYY-MM-DD)
// colorado.principalAddress principal office address, on one line
// colorado.principalCity principal office city
// colorado.principalState principal office state
// colorado.principalPostalCode principal office ZIP code
// colorado.principalCountry principal office country
// colorado.mailingAddress mailing address, on one line
// colorado.registeredAgent name of the registered agent (an organization or a person)
// colorado.registeredAgentAddress registered agent's address, on one line
//
// No API key is needed. An optional Socrata app token (for higher rate limits) can be entered
// in the API Key field. See README.md next to this file for the enricher settings.
//
// A record gets no result (nothing is stored) when it has no valid entity ID, when the entity ID
// isn't in the dataset, or when the API can't answer.
// ---- Settings -------------------------------------------------------------------------
// Vocabulary key to read. Add the same key to the Vocabulary and Properties field.
const ENTITY_ID_KEY = "organization.coloradoEntityId";
// The enricher replaces {APIKey} with the API Key field value: an optional data.colorado.gov
// (Socrata) app token. Leave the field empty to call the API without one.
const APP_TOKEN = "{APIKey}";
const COLORADO_URL = "https://data.colorado.gov/resource/4ykn-tg5h.json";
// How long to reuse an answer for the same entity ID. 0 turns caching off.
const CACHE_MILLISECONDS = 24 * 60 * 60 * 1000;
// ---- Script ---------------------------------------------------------------------------
// Entity type codes used by the Colorado Secretary of State
// (https://www.coloradosos.gov/pubs/business/helpFiles/abbreviations.html). A code with the
// suffix -PBC is the public benefit form of the same type.
const ENTITY_TYPES = {
CU: "Credit union",
DC55: "Domestic cooperative (Article 55)",
DC56: "Domestic cooperative (Article 56)",
DLLC: "Domestic limited liability company",
DLLLP: "Domestic limited liability limited partnership",
DLLP: "Domestic limited liability partnership",
DLP: "Domestic limited partnership",
DLPA: "Domestic limited partnership association",
DNC: "Domestic nonprofit corporation",
DPC: "Domestic profit corporation",
DT: "Ditch company",
FCOOP: "Foreign cooperative",
FLLC: "Foreign limited liability company",
FLLLP: "Foreign limited liability limited partnership",
FLLP: "Foreign limited liability partnership",
FLP: "Foreign limited partnership",
FLPA: "Foreign limited partnership association",
FNC: "Foreign nonprofit corporation",
FPC: "Foreign profit corporation",
IC: "Insurance company",
SL: "Savings and loan",
WC: "Water company",
};
function getValue(key) {
// A plain loop rather than vocabularies.find(...): vocabularies is a .NET list, and when
// .find is called from inside a function, later calls return the first call's match.
const items = vocabularies || [];
for (let i = 0; i < items.length; i++) {
if (items[i].Key === key) {
const value = items[i].Value;
return value === null || value === undefined ? "" : String(value).trim();
}
}
return "";
}
// Colorado entity IDs are 10 or 11 digits, for example 20031315478 (the first four digits are
// usually the year of filing). Spaces, dashes and dots are removed. Returns the ID or null.
function parseEntityId(raw) {
const text = raw.replace(/[\s.\-]/g, "").replace(/^0+/, "");
return /^\d{10,11}$/.test(text) ? text : null;
}
function clean(value) {
if (value === null || value === undefined) {
return null;
}
const text = String(value).replace(/\s+/g, " ").trim();
return text === "" ? null : text;
}
function parseJson(text) {
try {
return JSON.parse(text);
} catch (e) {
return null;
}
}
// Socrata dates look like "2003-10-03T00:00:00.000". Only the date is kept.
function formatDate(value) {
const text = clean(value);
return text && /^\d{4}-\d{2}-\d{2}/.test(text) ? text.substring(0, 10) : null;
}
// Joins address parts on one line, for example "320 South Canal Street, 36th Floor, Chicago, IL 60606, US".
function formatAddress(line1, line2, city, state, zip, country) {
const stateZip = [clean(state), clean(zip)].filter((x) => x).join(" ");
const parts = [clean(line1), clean(line2), clean(city), stateZip, clean(country)].filter((x) => x);
return parts.length > 0 ? parts.join(", ") : null;
}
function describeEntityType(code) {
const type = clean(code);
if (!type) {
return null;
}
const base = type.replace(/-PBC$/, "");
const description = Object.prototype.hasOwnProperty.call(ENTITY_TYPES, base) ? ENTITY_TYPES[base] : null;
if (!description) {
return null;
}
return base === type ? description : `${description} (public benefit)`;
}
function registeredAgent(row) {
const person = [clean(row.agentfirstname), clean(row.agentmiddlename), clean(row.agentlastname), clean(row.agentsuffix)]
.filter((x) => x).join(" ");
return clean(row.agentorganizationname) || clean(person);
}
// Calls the API. Returns the rows for the entity ID (possibly none), or null when the API can't
// answer.
function lookUp(entityId) {
const headers = [{ Key: "Accept", Value: "application/json" }];
if (clean(APP_TOKEN)) {
headers.push({ Key: "X-App-Token", Value: APP_TOKEN.trim() });
}
const apiResponse = http.send({
url: `${COLORADO_URL}?entityid=${entityId}`,
method: "GET",
headers: headers,
});
const status = String(apiResponse.HttpStatus || "");
const body = parseJson(apiResponse.Content);
if (status === "TooManyRequests") {
throw new Error("TooManyRequests - data.colorado.gov is throttling requests, the record will be retried");
}
if ((status === "Forbidden" || status === "Unauthorized") && clean(APP_TOKEN)) {
throw new Error(`data.colorado.gov rejected the app token in the API Key field (HTTP ${status}). ${body && body.message ? body.message : ""}`);
}
if (status === "OK" && Array.isArray(body)) {
return body;
}
log(`Colorado business entities could not look up entity ID ${entityId}. HTTP ${status}. ${String(apiResponse.Content || "").substring(0, 200)}`);
return null;
}
function run() {
const entityId = parseEntityId(getValue(ENTITY_ID_KEY));
if (!entityId) {
// No valid entity ID on this record (this is also what Test connection hits, because it
// passes placeholder values instead of real ones).
return [];
}
const cacheKey = `colorado:${entityId}`;
const cached = CACHE_MILLISECONDS > 0 ? cache.get(cacheKey) : null;
let row = cached ? parseJson(String(cached)) : null;
if (!row) {
const rows = lookUp(entityId);
if (!rows) {
return [];
}
// The entity ID is unique in the dataset, so there is at most one row.
row = rows.length > 0 && rows[0] && clean(rows[0].entityid) === entityId ? rows[0] : null;
if (!row) {
log(`Colorado business entities has no entity with ID ${entityId}.`);
return [];
}
if (CACHE_MILLISECONDS > 0) {
cache.set(cacheKey, JSON.stringify(row), CACHE_MILLISECONDS);
}
}
const data = {
"colorado.entityId": entityId,
"colorado.name": clean(row.entityname),
"colorado.status": clean(row.entitystatus),
"colorado.entityType": clean(row.entitytype),
"colorado.entityTypeDescription": describeEntityType(row.entitytype),
"colorado.jurisdiction": clean(row.jurisdictonofformation),
"colorado.formationDate": formatDate(row.entityformdate),
"colorado.principalAddress": formatAddress(row.principaladdress1, row.principaladdress2, row.principalcity,
row.principalstate, row.principalzipcode, row.principalcountry),
"colorado.principalCity": clean(row.principalcity),
"colorado.principalState": clean(row.principalstate),
"colorado.principalPostalCode": clean(row.principalzipcode),
"colorado.principalCountry": clean(row.principalcountry),
"colorado.mailingAddress": formatAddress(row.mailingaddress1, row.mailingaddress2, row.mailingcity,
row.mailingstate, row.mailingzipcode, row.mailingcountry),
"colorado.registeredAgent": registeredAgent(row),
"colorado.registeredAgentAddress": formatAddress(row.agentprincipaladdress1, row.agentprincipaladdress2,
row.agentprincipalcity, row.agentprincipalstate, row.agentprincipalzipcode, row.agentprincipalcountry),
};
// Leave out values the register didn't return, so they don't overwrite existing data with blanks.
Object.keys(data).forEach((key) => {
if (data[key] === null) {
delete data[key];
}
});
return [{ Data: data, Score: 100 }];
}
response = JSON.stringify(run());