CommonGrants protocol v0.6.0
This document outlines the technical specification for the CommonGrants protocol, which defines:
- The required routes, operations, and schemas for a CommonGrants API;
- The patterns for implementing custom behavior.
Not interested in the technical details? Check out:
- The OpenAPI docs for a high-level overview of the API endpoints supported by the protocol;
- The Models page for a detailed breakdown of the data elements defined by the protocol.
Definitions
Section titled “Definitions”The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “NOT RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in BCP 14, RFC2119, and RFC8174 when, and only when, they appear in all capitals, as shown here.
CommonGrants protocol
Section titled “CommonGrants protocol”The CommonGrants protocol defines a set of REQUIRED API routes, operations, and schemas that a CommonGrants API MUST implement to be considered compliant. It also defines an OPTIONAL pattern for extending the base protocol with implementation-specific behavior.
OpenAPI document
Section titled “OpenAPI document”An OpenAPI document is a JSON or YAML document that conforms to the OpenAPI Specification and formally describes an API.
API document
Section titled “API document”A CommonGrants API document is an OpenAPI document that conforms to the CommonGrants protocol and formally describes the routes and operations of a CommonGrants API.
Developers MAY draft their API document in TypeSpec, using the CommonGrants core library and CLI, before compiling it to an OpenAPI document. This approach allows developers to leverage features such as intellisense and compile-time checks that increase the likelihood of compliance with the CommonGrants protocol.
CommonGrants API
Section titled “CommonGrants API”A CommonGrants API is a software platform or system that implements all of the REQUIRED CommonGrants routes and operations, with an OPTIONAL set of implementation-defined extensions.
Routes and operations
Section titled “Routes and operations”CommonGrants routes and operations provide a formal description of CommonGrants API endpoints and the actions they perform, standardizing the interface between a CommonGrants API and its clients. These routes and operations are defined using TypeSpec and compile to an OpenAPI document.
There are three main categories of routes and operations:
- Required routes that are stable and MUST be implemented.
- Optional routes that are stable and MAY be implemented, but are NOT REQUIRED.
- Experimental routes that are unstable, intended for feedback, and are NOT REQUIRED.
Schemas
Section titled “Schemas”CommonGrants schemas formally describe how data SHOULD be represented within a CommonGrants API route or operation. These schemas are defined using TypeSpec and compile to other formats, such as OpenAPI schemas and JSON schemas.
Some CommonGrants schemas can be modified to support implementation-defined behavior.
Implementation-defined behavior
Section titled “Implementation-defined behavior”The protocol categorizes certain behaviors as implementation-defined, which means that CommonGrants APIs have modified the default behavior using a protocol-defined extension pattern. This pattern allows implementations to support custom functionality while maintaining consistency and compatibility with other CommonGrants APIs.
Compliance
Section titled “Compliance”An API is “compliant” with the CommonGrants protocol if:
- It correctly implements all required routes and operations, with inputs and outputs that conform to the corresponding CommonGrants schemas
- It does not implement any API endpoints that directly conflict with the optional routes and operations defined by the protocol
- It follows the guidelines outlined in the CommonGrants protocol for all implementation-defined extensions of any default routes, operations, and schemas
Developers MAY use the CommonGrants CLI to validate their API document and implementation against the CommonGrants protocol.
Specification
Section titled “Specification”Versions
Section titled “Versions”The CommonGrants protocol follows the Major.Minor.Patch versioning scheme, where:
- the
Majorversion is incremented when backwards-incompatible changes are made to the protocol. These changes may include:- Adding new required routes or operations;
- Adding new required fields to existing schemas;
- Removing existing fields from existing schemas;
- Removing an option from an existing enum field;
- Changing the type of an existing field; or
- Changing the protocol in other ways that would make existing CommonGrants APIs non-compliant.
- the
Minorversion is incremented when backwards-compatible changes are made to the protocol. These changes may include:- Adding new optional routes or operations;
- Adding new optional fields to existing schemas;
- Adding new options to existing enum fields; or
- Making other changes that introduce new functionality without making existing implementations non-compliant.
- the
Patchversion is incremented when the protocol is updated in ways that don’t change its contract. A patch never changes schemas, validation, required routes, or status codes; a fix that changes any of these is published as a newMinororMajorversion. Patch changes may include:- Updating the descriptions or metadata of existing routes, operations, and schemas in ways that don’t change their behavior;
- Fixing typos or other minor changes that don’t affect the protocol’s behavior; or
- Making other changes that leave schemas, validation, required routes, and status codes unchanged.
A CommonGrants API MAY serve more than one protocol version. A client selects a version with the CommonGrants version request header, CG-Version, and the server reports the version it served with the CommonGrants served-version response header, CG-Version-Served. The rest of this section defines how version negotiation works. The Versioning page explains it with examples, and ADR 0032 records the rationale.
The headers, version errors, and discovery route are declared from v0.6.0, and the published v0.1.0 through v0.5.0 contracts don’t change. A server that adopts version negotiation applies these rules to every protocol version it serves, including v0.5.0 and earlier.
It is RECOMMENDED that a server move all its routes to a new version at the same time. A server MAY instead serve different versions on different routes, and advertise those routes in discovery.
Requesting a version
Section titled “Requesting a version”- A client selects a version only with the
CG-Versionrequest header. Servers MUST NOT read a version from the URL path, the query string, theAcceptheader, or a vendor media type, and MUST NOT fall back to one. CG-Versionapplies only to protocol routes under/common-grants/, relative to the API’s base URL. Servers MUST ignore it on custom routes and on the discovery route. A host API MAY mount the protocol routes under its own path, such as/api/v2/common-grants/; the host’s path version andCG-Versionare independent.- The value MUST be a full published protocol version: three dot-separated numbers with no leading zeros, such as
0.5.0. Avprefix, a short form such as0.5, ranges, and aliases are malformed. The header name is case-insensitive, and servers MUST trim surrounding whitespace before matching the format. - A request MUST carry at most one value. Because a proxy may fold two header lines into one comma-separated line (RFC 9110 §5.3), servers MUST treat two header lines, or a comma in the value, as more than one value, and MUST check for that before checking the format.
- Servers MUST match the requested version on major and minor. A server MUST host one patch of each major and minor version it serves and MUST report that full version wherever it lists or reports it. It serves a request for any patch of that major and minor in the version it hosts. For example, a request for
0.5.0is served by a server hosting0.5.1. - A server MUST NOT serve a different major or minor version than the one requested, even if it serves only one version.
- A request without
CG-Versionis served in the server’s default version: the baseline default, or the route’s own default when discovery lists the route. A server adopting version negotiation MUST set its default to the version it already serves, and adding versions MUST NOT change the default. A default changes only as described in Changing the default version. - One request is served in one version. The whole response, including nested objects, MUST follow that version’s schemas, and the request body MUST be validated against them.
- A server MUST match the route, then resolve the version, then validate the request body, all before any side effect. A route the server doesn’t implement returns an ordinary 404. A rejected write MUST change nothing and MUST NOT be retried under another version.
Version response headers
Section titled “Version response headers”- Every response produced after a version is selected MUST carry
CG-Version-Servedwith the full version served, including responses served by default and errors such as a missing record or a request body that fails validation. Responses to 401 and 403 MAY omit it, because authentication can run before a version is selected. Version errors MUST NOT carry it. - The served version travels in headers only. Response bodies are the same as in a server that doesn’t negotiate versions.
- A successful response without
CG-Version-Servedis unconfirmed: the server may predate version negotiation, or something between the client and the server dropped the request header. A response whose served major or minor version differs from the one requested wasn’t served as requested. Clients can’t assume either was served in the version they asked for. - Every cacheable response that depends on
CG-VersionMUST carryVary: CG-Version, including responses served by default. - Cross-origin servers MUST allow
CG-VersioninAccess-Control-Allow-Headers, and MUST exposeCG-Version-Served,Deprecation,Sunset, andLinkinAccess-Control-Expose-Headers. - Ordinary responses MUST NOT carry a header listing the supported versions. The discovery route and the
version.unsupportedandversion.retirederrors carry that list. - Version header names use hyphens and no
X-prefix.
Version errors
Section titled “Version errors”A version problem returns one of the following errors. It MUST NOT return 404 or 410, because both can be cached by default and clients read them as a missing route or record.
| Case | code |
Status |
|---|---|---|
Malformed version, such as banana or 0.5 |
version.malformed |
400 |
| More than one version value, as two header lines or one comma-separated line, even the same value twice | version.conflict |
400 |
| Version this server, or this route, doesn’t serve | version.unsupported |
406 |
| Version retired from this server or this route | version.retired |
406 |
Each error uses the standard error response envelope, with one entry in errors whose field is CG-Version and whose code is one of the values above. Every entry carries supported and defaultVersion, which describe the route that was called, and the server’s discovery URL in discovery when it publishes one. version.unsupported and version.retired also carry the requested version and a scope of deployment (the whole server) or operation (only this route). version.retired also carries the sunset date in RFC 3339 format. version.malformed carries the requested value as sent, and version.conflict omits requested. code values are stable, so clients branch on them. The Versioning page shows the full schemas.
After a version’s sunset date, requests for it get version.retired, as described in Retiring a version.
Discovering supported versions
Section titled “Discovering supported versions”GET /common-grants/versions lists the protocol versions a server serves. The route is OPTIONAL, but a server that serves more than one protocol version MUST implement it (see Version routes).
- The route MUST NOT require stronger authentication than the API’s required routes, and SHOULD be readable without authentication.
- It takes no request parameters, ignores
CG-Version, and never returns a version error. Its responses carry neitherCG-Version-ServednorVary: CG-Version. - It returns the standard success envelope. In
data,versionsanddefaultVersionare the baseline, which applies to every route without an entry inoperations. A route whose versions differ from the baseline has an entry inoperations, keyed by its HTTP method and its path as published in the protocol, such asGET /common-grants/forms/{formId}. Path parameter names are ignored when matching a key to a route. A server whose routes all serve the baseline omitsoperations. - A route serves a version only if that version of the protocol defines the route.
- Every route a baseline version requires serves that version, so the baseline is a compliance claim: the server is compliant with every version in it. Supporting a version doesn’t mean implementing that version’s optional or experimental routes.
- A default is always one of the versions it applies to, and
upcomingDefault.versionMUST be one of theversionsit applies to. - The optional
upcomingDefaultanddeprecatedfields appear only while a change is pending: at the top level for the baseline, or in a route’s entry for that route only. Their dates use RFC 3339. - Each key in
deprecatedMUST be a version from theversionsbeside it, written exactly as it appears there. A client finds the entry for the version it requested by comparing only the major and minor: a client requesting0.3.0from a server that lists0.3.1finds its entry under0.3.1. - Fields are only ever added to the discovery response. Clients MUST ignore fields they don’t recognize, and accept version values published after they were built.
A client that gets 404 from the discovery route treats the server as serving one version that it doesn’t advertise.
Retiring a version
Section titled “Retiring a version”A server retires a version the same way whether the version is leaving the whole server or one route:
- On every response served in that version on the affected routes, the server MUST send the
Deprecationheader (RFC 9745), and, once a date is set, theSunsetheader (RFC 8594).Deprecationuses the@<unix-timestamp>form, such as@1796083200, andSunsetuses an HTTP-date, such asTue, 01 Jun 2027 00:00:00 GMT. Both headers keep their standard meaning and always describe the version the response was served in. - Alongside them, the server MUST send
Linkheaders (RFC 8288) withrel="deprecation"andrel="sunset"pointing to migration documentation, and withrel="version-history"pointing to the discovery route. - Discovery MUST list the version under
deprecatedwith itsdeprecationdate and, once set, itssunsetdate: at the top level when the version is leaving the whole server, or in the route’s entry when it’s leaving one route. - After the sunset date, the server MUST answer requests for the version with
version.retired, as described in Version errors, for a period it chooses, and MAY answerversion.unsupportedafter that. - If the version is a default, the server MUST move that default forward to the next newer version no later than the sunset date, announcing the change as described in Changing the default version. Responses served by default then carry both the retirement headers and the
successor-versionlink. A server can’t retire a default unless it serves a newer version for the default to move to. - A required route can’t drop a baseline version that requires the route, so retiring that version from the route means retiring it from the baseline.
- Experimental routes MAY drop a version without notice.
Changing the default version
Section titled “Changing the default version”A server MAY change a default version whether or not it keeps serving the old one. Before the change, it MUST announce it:
- On responses served by default from the affected routes, the server MUST send a
Linkheader withrel="successor-version"(RFC 5829) pointing to documentation for the new default, and aLinkheader withrel="version-history"pointing to the discovery route. - Discovery MUST show
upcomingDefaultwith the new default’sversionand thedateit takes effect: at the top level for the baseline default, which also covers route entries whose default follows the baseline, or in a route’s entry for that route’s own default. - The server MUST NOT send
DeprecationorSunsetfor a default change. They appear on responses served by default only when the default version is itself retiring.
Responses to requests that name a version don’t change. At the announced date, the default moves to the next newer version it applies to.
Migration notes
Section titled “Migration notes”Guidance for implementers and consumers moving between protocol versions. Each entry is written as its changes land and is reviewed again before the version is published.
v0.6.0
Section titled “v0.6.0”v0.6.0 adds version negotiation and is purely additive: nothing changes for existing clients or servers. The published v0.1.0 through v0.5.0 contracts are unchanged, and a server that doesn’t adopt version negotiation stays compliant with the versions it already implements.
Version negotiation
Section titled “Version negotiation”- Every protocol route except
GET /versionsdeclares the optionalCG-Versionrequest header, and its responses declareCG-Version-Served,Vary,Deprecation,Sunset, andLink. 401 and 403 responses declareCG-Version-Servedas optional. See Version response headers. - Every protocol route except
GET /versionsdeclares the version errors: 400version.malformedandversion.conflict, and 406version.unsupportedandversion.retired. See Version errors. - The new optional
GET /versionsroute lists the versions a server serves. A server that serves more than one version MUST implement it. See Discovering supported versions. - A new
protocolVersionscalar describes a fullMAJOR.MINOR.PATCHprotocol version, such as0.6.0.
Adopting version negotiation
Section titled “Adopting version negotiation”A server that adopts version negotiation pins its default to the version it already serves, so clients that send no CG-Version keep getting the contract they use today. It sends CG-Version-Served on every response produced after a version is selected, whatever version it serves, and Vary: CG-Version on cacheable responses. A client of an older version gets one extra response header and, because it sends no CG-Version, never a version error.
A client can start sending CG-Version to fix the contract it’s served in, read CG-Version-Served to confirm what it got, call the discovery route to find the versions a server serves, and watch for Deprecation, Sunset, and successor-version links. The Versioning page walks through each step.
v0.5.0
Section titled “v0.5.0”v0.5.0 renames two fields on competitions and forms, which is a breaking change for anyone who serializes or reads them. Every other change is additive and optional, and the award routes move from experimental to optional.
Breaking changes
Section titled “Breaking changes”CompetitionBasereplaces the requiredopportunityIdwith a requiredopportunityreference (OppRef), which carries the linked opportunity’sidandtitle, and optionally itsidentifiers. Producers need the opportunity’s title when they serialize a competition. See migrating competitions.FormBaserenames the requirednamefield totitle. Form contents, JSON and UI schemas, and mappings are unchanged. See migrating forms.
The competition and form routes are experimental. Competitions also appear in the optional competitions field of OpportunityDetails, which the required GET /opportunities/{oppId} route returns, so an implementation that populates that field must update the competitions and forms inside it when it moves to v0.5.0. Applications are unaffected: ApplicationBase keeps its competitionId and opportunityId fields.
Opportunities
Section titled “Opportunities”OppRefgains an optionalidentifierscollection, so theopportunityreference carried byAwardBaseandCompetitionBasecan publish registry-scoped identifiers such asopp:us:fon(Federal Opportunity Number) andopp:us:aln(Assistance Listing Number) alongside the opportunity’sidandtitle.OpportunityBasegains optionalidentifiersandfunderscollections, which an award consumer encounters when it reads the opportunity that an award points at.OpportunityDetailsgains an optionalawardsarray ofAwdRef, publishing the opportunity-to-award link in the reverse direction.- The
agencycustom field is deprecated for opportunities in favor offunders. See migrating fromagencytofunders.
Organizations
Section titled “Organizations”OrganizationBasegains an optionalstatus(active,inactiveorcustom), which records whether the organization still exists and operates.OrganizationBasegains an optionalaliaseslist and an optionalrelationshipsobject, whose lists record an organization’s parents, children, successors, predecessors, replacement records, and other connections.aliasesitems use a newTypes.nonEmptyStringscalar, and the parent and child kinds includedbafor a record that is a name its legal entity does business under. See the organization relationships guide.OrgPatchDatacan set or clearstatus,aliasesandrelationships.- The
OrgRef.namedescription is reworded to “The name this organization is known by; for a legal entity, its legal name,” which also changesOrganizationBase.name. This is description-only.
Validators that reject unknown properties need the v0.5.0 schemas before they read these fields. A consumer that converts records down to v0.4.0 should keep the relationship, aliases and status data somewhere rather than silently drop it, because v0.4.0 has no place for it.
Awards
Section titled “Awards”The three award routes move from experimental to optional in v0.5.0. This obliges no implementation to serve them, since optional routes MAY be omitted and the set of required routes is unchanged. It does change their stability guarantee: a breaking change to an award route now requires incrementing the Major version under the rules above, instead of being exempt the way changes to experimental routes are.
Validating with the CLI
Section titled “Validating with the CLI”Three notes for anyone validating an implementation with the CommonGrants CLI:
- The CLI selects a bundled copy of each protocol version’s spec, and releases so far bundle versions up to v0.4.0, so
cg check spec --protocol-version 0.5.0needs a CLI release that bundles v0.5.0. Until then, pass the v0.5.0 OpenAPI document published on this site with--base. - Route status is an OpenAPI tag, and tags are not versioned, so the v0.4.0 OpenAPI document published on this site also labels the award routes optional. The copy of the v0.4.0 spec bundled with the CommonGrants CLI is unchanged and still labels them experimental, so
cg check spec --protocol-version 0.4.0behaves as it did before. cg check specclassifies a missing optional route as a warning. CLI releases before #1259 still count that warning in the reported error total and fail the run. From the first@common-grants/clirelease that includes #1259, a run whose only findings are warnings prints them, marks each one(warning), and passes. This only arises when the base spec being validated against labels the award routes optional, which is true of the v0.5.0 and v0.4.0 documents published on this site. On a CLI release without the fix,cg check spec --protocol-version 0.4.0is the workaround, because the v0.4.0 spec bundled with the CLI still labels the award routes experimental. That bundled spec is a generated artifact, so the workaround holds only until the CLI reships it.
Schemas
Section titled “Schemas”The CommonGrants protocol defines the following schemas that are used to represent data in CommonGrants APIs. The schemas are loosely organized into the following categories:
- Types: Foundational data types, like strings, numbers, etc.
- Fields: Standardized fields that are reused across models.
- Opportunity Models: Domain-specific models for funding opportunities.
- Apply Models: Domain-specific models for the application process.
Base types
Section titled “Base types”String types
| Type | Description |
|---|---|
| string | A sequence of characters |
| uuid | A universally unique identifier |
| url | A Uniform Resource Locator (URL) |
| An email address | |
| employerTaxId | An Employer Identification Number (EIN) |
| samUEI | A Unique Entity Identifier (UEI) assigned by the System for Award Management (SAM) |
| duns | A Data Universal Numbering System (DUNS) number |
Numeric types
| Type | Description |
|---|---|
| numeric | A number with an arbitrary precision and scale |
| integer | A whole number without decimals |
| decimalString | A decimal number encoded as a string to preserve scale |
Date and time types
| Type | Description |
|---|---|
| isoTime | Time without timezone in ISO 8601 format (HH:mm:ss) |
| isoDate | Calendar date in ISO 8601 format (YYYY-MM-DD) |
| utcDateTime | Datetime with UTC timezone in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ) |
| offsetDateTime | Datetime with timezone in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm) |
| calendarYear | A calendar year in the format YYYY |
Other types
| Type | Description |
|---|---|
| boolean | A true or false value |
| array | An ordered list of values |
| record | A collection of key-value pairs |
| null | A null value |
| unknown | A value of with any type |
Core fields
Section titled “Core fields”The CommonGrants protocol defines the following fields that are reused across models:
| Field | Description |
|---|---|
| Money | A monetary amount with a currency code |
| Event | A description of an event with an associated date |
| CustomField | A model for defining custom fields on a record |
| SystemMetadata | System-managed metadata for records |
| Address | A physical address |
| File | A file attachment |
| Name | A person’s name |
| Phone | A phone number |
| PCS term | A Philanthropy Classification System (PCS) term |
Opportunity models
Section titled “Opportunity models”The CommonGrants protocol defines the following models that are specific to funding opportunities:
| Model | Description |
|---|---|
| OpportunityBase | The core model for a funding opportunity |
| OppStatus | The status of an opportunity |
| OppFunding | Details about the funding available for an opportunity |
| OppTimeline | Key dates in the opportunity’s timeline |
Apply models
Section titled “Apply models”The CommonGrants protocol defines the following models that are specific to the application process:
Application models
| Model | Description |
|---|---|
| ApplicationBase | The core model for an application to a competition |
| AppStatus | The status of an application |
| AppStatusOptions | The set of values accepted for application status |
| AppFormResponse | A form response included in an application |
Competition models
| Model | Description |
|---|---|
| CompetitionBase | The core model for a competition |
| CompetitionStatus | The status of a competition |
| CompetitionStatusOptions | The set of values accepted for competition status |
| CompetitionForms | The forms required for a competition |
| CompetitionTimeline | Key dates in the competition’s timeline |
Form models
| Model | Description |
|---|---|
| FormBase | A form for collecting data from a user |
| FormJsonSchema | A JSON schema used to validate form responses |
| FormUISchema | A UI schema used to render the form in the browser |
Form response models
| Model | Description |
|---|---|
| FormResponseBase | The core model for a form response |
| FormResponseStatus | The status of a form response |
| FormResponseStatusOptions | The set of values accepted for form response status |
Mapping models
| Model | Description |
|---|---|
| MappingSchema | A mapping format for translating data between schemas |
| MappingFunction | The set of supported mapping functions |
| MappingConstantFunction | Returns a constant value |
| MappingFieldFunction | Returns the value of a field in the source data |
| MappingSwitchFunction | Returns a new value based on a switch statement |
Applicant type models
| Model | Description |
|---|---|
| ApplicantType | The type of applicant eligible to apply for funding |
| ApplicantTypeOptions | The set of possible applicant types |
Routes and operations
Section titled “Routes and operations”The CommonGrants protocol defines the following routes and operations that are specific to funding opportunities and the application process.
Opportunity routes
Section titled “Opportunity routes”| Route | Status | Description |
|---|---|---|
GET /opportunities |
Required | Get a paginated list of opportunities sorted by lastModifiedAt |
GET /opportunities/{oppId} |
Required | View details about a specific opportunity |
POST /opportunities/search |
Optional | Search and filter funding opportunities |
Award routes
Section titled “Award routes”| Route | Status | Description |
|---|---|---|
GET /awards |
Optional | Get a paginated list of awards sorted by lastModifiedAt |
GET /awards/{awdId} |
Optional | View details about a specific award |
POST /awards/search |
Optional | Search and filter awards |
The award routes were experimental in v0.4.0 and are optional as of v0.5.0, which means a CommonGrants API MAY implement them. They are optional rather than required because an implementation that publishes funding opportunities does not necessarily hold award data, and making the routes required would render those implementations non-compliant. Because they are no longer experimental, breaking changes to these routes now follow the versioning rules in Versions rather than the exemption that applies to experimental routes. See the v0.5.0 migration notes for what the change means when validating an implementation against a v0.4.0 base spec.
Version routes
Section titled “Version routes”| Route | Status | Description |
|---|---|---|
GET /versions |
Optional | List the protocol versions this API serves |
The version discovery route was added in v0.6.0. It is optional, but a server that serves more than one protocol version MUST implement it. A route status can’t express that condition, so the requirement lives in this text rather than in the route’s status. See Discovering supported versions.
Organization routes
Section titled “Organization routes”| Route | Status | Description |
|---|---|---|
GET /orgs |
Experimental | Get a paginated list of organization profiles |
GET /orgs/{orgId} |
Experimental | View a specific organization profile |
PATCH /orgs/{orgId} |
Experimental | Update an organization profile |
POST /orgs/{orgId}/changes |
Experimental | Submit a change to an organization profile |
GET /orgs/{orgId}/changes |
Experimental | Get a paginated list of changes to an organization profile |
GET /orgs/{orgId}/changes/{changeId} |
Experimental | View a specific change to an organization profile |
Competition routes
Section titled “Competition routes”| Route | Status | Description |
|---|---|---|
GET /competitions/{compId} |
Experimental | View details about a specific competition |
Application routes
Section titled “Application routes”| Route | Status | Description |
|---|---|---|
POST /applications/start |
Experimental | Start a new application for a given competition |
GET /applications/{appId} |
Experimental | View an application for a given competition |
PUT /applications/{appId}/submit |
Experimental | Submit an application to a competition |
PUT /applications/{appId}/forms/{formId} |
Experimental | Respond to a form in an application |
GET /applications/{appId}/forms/{formId} |
Experimental | View form responses in an application |
Form routes
Section titled “Form routes”| Route | Status | Description |
|---|---|---|
GET /forms |
Experimental | Get a paginated list of forms sorted by lastModifiedAt |
GET /forms/{formId} |
Experimental | View details about a specific form |
Pagination
Section titled “Pagination”CommonGrants routes that return multiple records from a resource SHOULD support pagination. Paginated routes SHOULD accept the following, either as query parameters (for GET routes) or as properties in a pagination object at the root of the request body (for POST and PUT routes):
| Parameter | Type | Default | Description |
|---|---|---|---|
page |
integer | 1 | The page number to return, starting at 1 |
pageSize |
integer | 100 | The number of results per page, between 1 and 100 |
Additionally, the response body for paginated requests SHOULD include a paginationInfo property with the following:
| Property | Type | Required | Description |
|---|---|---|---|
page |
integer | Yes | The page number of the results |
pageSize |
integer | Yes | The number of results per page |
totalItems |
integer | Yes | The total number of results across all pages |
totalPages |
integer | Yes | The total number of pages of results |
The response body for paginated requests SHOULD return the paginated set of records in the items property.
Sorting
Section titled “Sorting”CommonGrants routes that support sorting SHOULD accept the following, either as query parameters (for GET routes) or as an properties in a sorting parameter in the request body (for POST and PUT routes):
| Parameter | Type | Description |
|---|---|---|
sortBy |
string | The property to use to sort the results |
customSortBy |
string | The implementation-defined sort value, if applicable |
sortOrder |
asc or desc |
The order in which to sort the results |
Additionally, the response body for sorted requests SHOULD include a sortInfo property with the following:
| Property | Type | Required | Description |
|---|---|---|---|
sortBy |
string | Yes | The property used to sort the results, or custom if a custom sort was used |
customSortBy |
string | No | The custom sort value used, if applicable |
sortOrder |
asc or desc |
Yes | The order in which the results were sorted |
errors |
array | No | Errors that occurred while sorting |
If the protocol specifies a minimum set of sortBy options, implementations MUST support them. APIs MAY support additional implementation-defined options using the customSortBy parameter.
To maintain compatibility, if a client uses an unsupported customSortBy value, the API SHOULD NOT return a non-2xx response. Instead, it SHOULD default to the standard sortBy value and note the error in sortInfo.errors.
Filtering
Section titled “Filtering”CommonGrants routes that support filtering SHOULD be paginated POST operations that accept a filters parameter at the root of the request body, with one or more supported filters defined by the protocol.
The value of each protocol-defined filter SHOULD conform to the Filter schema, which contains the following properties:
| Property | Type | Required | Description |
|---|---|---|---|
operator |
enum | Yes | The operation to perform on the value |
value |
any | Yes | The data to use for the filter operation |
The operator property SHOULD be one of the following, though individual filters are NOT REQUIRED to support all operations:
| Operation | Description | Supported value types |
|---|---|---|
eq |
Equal to | string, number, boolean, date, money |
neq |
Not equal to | string, number, boolean, date, money |
gt |
Greater than | number, date, money |
gte |
Greater than or equal to | number, date, money |
lt |
Less than | number, date, money |
lte |
Less than or equal to | number, date, money |
like |
String contains | string |
not_like |
String does not contain | string |
in |
In list | array |
not_in |
Not in list | array |
between |
Between two values | range object with min and max properties |
Additionally, the response body for filtered requests SHOULD return the filtered set of records in the items property of a paginated response. This response body SHOULD also include a filterInfo property with the following:
| Property | Type | Required | Description |
|---|---|---|---|
filters |
object | Yes | The filters object from the request body |
errors |
array | No | Errors that occurred while filtering |
As an example, the POST /opportunities/search route may define the following schema for its filters request body parameter:
id: OpportunitySearchFilters.yamlfilters: type: object properties: title: description: Filter opportunities by title type: object properties: value: type: string operation: type: string enum: - eq - neq - like closedDateRange: description: Filter opportunities closed between two dates type: object properties: value: type: object properties: min: type: string format: date max: type: string format: date operation: type: string enum: - eq - neq - gt - gte - lt - lte required: - operationWhich would accept the following request body:
{ "filters": { "title": { "value": "example", "operation": "like" }, "closedDateRange": { "value": { "min": "2024-01-01", "max": "2024-01-31" }, "operation": "between" } }}And return the following response body:
{ "items": [ // filtered results ], "paginationInfo": { // pagination info }, "filterInfo": { "filters": { "title": { "value": "example", "operation": "like" }, "closedDateRange": { "value": { "min": "2024-01-01", "max": "2024-01-31" }, "operation": "between" } }, "errors": [] }}For more information about implementation-defined filters, see the Custom filters section.
Extensions
Section titled “Extensions”The CommonGrants protocol defines the following mechanisms for extending the base protocol with implementation-defined behavior:
Custom fields
Section titled “Custom fields”CommonGrants APIs may need to support attributes that are not explicitly included in the default schemas. To support this, the CommonGrants protocol has defined a pattern for adding custom fields to certain models, e.g. OpportunityBase.
If a model supports custom fields, it MUST include an optional customFields property, an object whose values MUST conform to the CustomField type. CommonGrants APIs MAY use this customFields property to define custom fields for its implementation of that model.
For example, to maintain compatibility with existing systems, a CommonGrants API might need each Opportunity record to have an id field that is an integer instead of a uuid. This API can create an implementation-defined version of the OpportunityBase schema with the following:
type: objectproperties: id: type: string examples: - 30a12e5e-5940-4c08-921c-17a8960fcf4b format: uuid description: Globally unique id for the opportunity title: type: string description: Title or name of the funding opportunity # other fields omitted for brevity customFields: type: object properties: legacyId: type: object properties: name: type: string const: Legacy ID type: type: string const: number value: type: integer examples: - 12345 description: type: string const: An integer ID for the opportunity, needed for compatibility with legacy systems required: - name - type - value required: - legacyIdrequired: - id # other required fields omitted for brevity - customFieldsIn this example, the API extends the OpportunityBase model to include a legacyId custom field, defined using the CustomField type.
Implementation-defined extensions MAY make the customFields property required if the base schema includes it as optional, but SHALL NOT add a customFields property to a model that lacks one.
Similarly, APIs SHALL NOT add fields outside the customFields property. If a model lacks a customFields property, it doesn’t support extension through custom fields.
Custom enum values
Section titled “Custom enum values”Some CommonGrants schemas have fields that accept values from a limited set of options, known as “enums”. Occasionally, APIs need to set these fields to implementation-defined custom values.
To support this, the protocol defines a pattern for custom enum values. If a field supports custom enum values, it MUST match an object with these properties:
value: a required string that includescustomas one of its enum valuescustomValue: an optional string with the display value for the custom enumdescription: an optional string that describes how to interpret the custom enum
properties: value: type: string enum: # other enum values added here - custom customValue: type: string description: The display value for the custom enum description: type: string description: A human-readable description of the valuerequired: - valueFor example, the OpportunityBase model includes a status with predefined values (e.g. forecasted, closed). When an opportunity’s status is set to one of these predefined values, it MUST include the value property and SHOULD omit the customValue and description properties:
{ "id": "ad763210-5940-4c08-921c-17a8960fcf4b", "title": "Example Opportunity", // other OpportunityBase fields omitted for brevity "status": { "value": "forecasted" }}When set to a custom value, it SHOULD include customValue and description:
{ "id": "ad763210-5940-4c08-921c-17a8960fcf4b", "title": "Example Opportunity", // other OpportunityBase fields omitted for brevity "status": { "value": "custom", "customValue": "archived", "description": "Opportunity will no longer appear in search results, but will remain in the system for reporting purposes" }}CommonGrants APIs SHALL NOT add custom enum values to any field that does not support them in the base protocol.
Custom filters
Section titled “Custom filters”If a route supports implementation-defined filters, it MUST include a customFilters property in its filters request body parameter. This property must be an object whose values match the Filter schema described in the Filtering section.
For example, to allow clients to filter opportunities by a custom field, an API can define this filter:
id: OpportunityCustomFilter.yamlfilters: type: object # protocol-defined filters omitted for brevity customFilters: type: object properties: agency: description: Filter opportunities by a list of agencies type: object properties: value: type: array items: type: string operation: type: string enum: - in - not_inFor compatibility, if a client provides an unsupported custom filter, the API SHOULD NOT return a non-2xx response. Instead, it SHOULD exclude that filter and note the error in filterInfo.errors.
For example, if a client provides an unsupported agencyType filter, the API SHOULD exclude it and return the following response body:
{ "filterInfo": { "filters": { "agencyType": { "value": ["federal"], "operation": "in" } }, "errors": ["Unsupported filter: agencyType"] }}Custom routes
Section titled “Custom routes”CommonGrants APIs MAY define custom routes that are not part of the core protocol. Any path that is not prefixed with /common-grants/ is considered a custom route.
For example, to allow clients to access the history of an opportunity record, an API can define this route:
/opportunities/{opportunityId}/history/: get: summary: Get opportunity history description: Get the history of changes made to an opportunityThis pattern can also be used to maintain support for existing routes that conflict with those defined by the protocol. For example, an API can maintain a non-conforming GET /common-grants/opportunities route by defining their own GET /opportunities route (without the /common-grants prefix):
/opportunities/: get: summary: Get opportunities (legacy) description: Get a list of opportunities, with legacy filtering and sortingThis allows APIs to incrementally adopt the CommonGrants protocol while supporting existing routes and operations.
Appendix A: Non-compliant examples
Section titled “Appendix A: Non-compliant examples”This appendix contains examples of changes to a CommonGrants API document that are non-compliant with the protocol.
Extra routes
Section titled “Extra routes”The implementation includes an extra route that is prefixed with /common-grants/, but is not part of the base protocol.
Base protocol
openapi: 3.0.0info: title: CommonGrants Base API description: Base protocol specification to check a CommonGrants API againsttags: - name: Opportunities - name: requiredpaths: /common-grants/opportunities: get: # omitted for brevity tags: - name: Opportunities - name: requiredImplementation with extra route
openapi: 3.0.0info: title: CommonGrants implementation API description: Implementation of the CommonGrants protocoltags: - name: Opportunitiespaths: /common-grants/opportunities: post: # omitted for brevity tags: - name: Opportunities get: # omitted for brevity tags: - name: OpportunitiesMissing routes
Section titled “Missing routes”The implementation does not include a required route.
Base protocol
openapi: 3.0.0info: title: CommonGrants Base API description: Base protocol specification to check a CommonGrants API againsttags: - name: Opportunities - name: requiredpaths: /common-grants/opportunities: get: # omitted for brevity tags: - name: Opportunities - name: required /common-grants/opportunities/{id}: get: # omitted for brevity tags: - name: Opportunities - name: requiredImplementation with missing route
openapi: 3.0.0info: title: CommonGrants implementation API description: Implementation of the CommonGrants protocoltags: - name: Opportunitiespaths: /common-grants/opportunities: get: # omitted for brevity tags: - name: Opportunities # missing GET /opportunities/{id} routeMismatched schemas
Section titled “Mismatched schemas”The implementation schemas are not valid against the base protocol schemas in one of the following ways:
- The implementation schema misses a required field.
- The implementation schema includes additional properties at the root of the schema.
- The implementation schema assigns the wrong type to an existing field.
- The implementation schema adds to the list of enum values for an existing field.
Base protocol
openapi: 3.0.0info: title: CommonGrants Base API description: Base protocol specification to check a CommonGrants API againsttags: - name: Opportunities - name: requiredpaths: /common-grants/opportunities: get: # omitted for brevity tags: - name: Opportunities - name: required responses: "200": description: A 200 response with a paginated list of items content: application/json: schema: type: object required: - id - title properties: id: type: string format: uuid title: type: string status: type: string enum: - forecasted - open - closed - custom # other OpportunityBase fields omitted for brevityImplementation with mismatched schemas
openapi: 3.0.0info: title: CommonGrants implementation API description: Implementation of the CommonGrants protocoltags: - name: Opportunitiespaths: /common-grants/opportunities: get: # omitted for brevity tags: - name: Opportunities - name: required responses: "200": description: A 200 response with a paginated list of items content: application/json: schema: type: object required: - id - title properties: id: type: integer # wrong type # missing title field agency: type: string status: type: string enum: # adds an unsupported enum value "archived" - forecasted - open - closed - custom - archived # other OpportunityBase fields omitted for brevity