Success
Success
Section titled “Success”Base model for all successful responses.
Version headers
Section titled “Version headers”From v0.6.0, the typed OkT<T>, CreatedT<T> and AcceptedT<T> responses carry the version response headers declared in Headers.VersionResponse: CG-Version-Served, which reports the full protocol version the response was served in, and the optional Vary, Deprecation, Sunset and Link headers. See Versioning and the Versions section of the specification. The VersionDiscoveryResponse carries none of them.
| Parameter | Type | Description |
|---|---|---|
| status | integer | The HTTP status code |
| message | string | The message to return |
Formats
Section titled “Formats”A JSON example of this model.
{ "status": 200, "message": "Success"}The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: Success.yamltype: objectproperties: status: type: integer minimum: -2147483648 maximum: 2147483647 examples: - 200 message: type: string examples: - Successrequired: - status - messageThe TypeSpec code for this model.
@Versioning.added(CommonGrants.Versions.v0_1)model Success { @example(200) status: int32;
@example("Success") message: string;}The Python code for this model.
class Success(DefaultResponse): """Default success response."""
status: int = Field( default=200, description="The HTTP status code", examples=[200], ) message: str = Field( default="Success", description="The message", examples=["Success"], )The TypeScript code for this model.
export const SuccessSchema = z.object({ /** HTTP status code */ status: z.number().int(),
/** Success message */ message: z.string(),});Changelog
Section titled “Changelog”| Version | Changes | Schema |
|---|---|---|
| 0.1.0 |
| Success.yaml |
A 200 response with data.
| Parameter | Type | Description |
|---|---|---|
| status | integer | The HTTP status code |
| message | string | The message to return |
| data | any | The data to return |
Formats
Section titled “Formats”A JSON example of this model.
{ "status": 200, "message": "Success", "data": { "id": "123", "name": "Test 1" }}The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: Ok.yamltype: objectproperties: data: description: Response datarequired: - dataallOf: - $ref: Success.yamlunevaluatedProperties: not: {}description: A 200 response with dataThe TypeSpec code for this model.
/** A 200 response with data of an unspecified shape * * Routes use the typed `OkT<T>` variant. */@doc("A 200 response with data")@Versioning.added(CommonGrants.Versions.v0_1)model Ok extends Success { /** Response data */ data: unknown;}Use the OkT<T> template to define a 200 response with typed data within an API operation:
import "@common-grants/core";import "@typespec/http";
using TypeSpec.Http;using CommonGrants.Responses;
model TestModel { id: string; name: string;}
@summary("Get test")@doc("Get a test model")@getop getTest(): OkT<TestModel>;Changelog
Section titled “Changelog”| Version | Changes | Schema |
|---|---|---|
| 0.1.0 |
| Ok.yaml |
VersionDiscoveryResponse
Section titled “VersionDiscoveryResponse”A 200 response listing the protocol versions an API serves, returned by the version discovery route, GET /common-grants/versions. Added in v0.6.0.
Discovery sits outside version selection, so unlike the other success responses this response carries no version headers: neither CG-Version-Served nor Vary. See Finding the supported versions for how clients use it.
| Parameter | Type | Description |
|---|---|---|
| status | integer | The HTTP status code |
| message | string | The message to return |
| data | VersionDiscovery | The protocol versions the API serves |
Formats
Section titled “Formats”A JSON example of this model.
{ "data": { "versions": [ "0.3.0", "0.4.0", "0.5.0" ], "defaultVersion": "0.4.0", "upcomingDefault": { "version": "0.5.0", "date": "2027-03-01T00:00:00Z" }, "deprecated": { "0.3.0": { "deprecation": "2026-12-01T00:00:00Z", "sunset": "2027-06-01T00:00:00Z" } } }, "status": 200, "message": "Success"}The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: VersionDiscoveryResponse.yamltype: objectproperties: data: $ref: VersionDiscovery.yaml description: The protocol versions the API servesrequired: - dataallOf: - $ref: Success.yamlunevaluatedProperties: not: {}description: A 200 response listing the protocol versions an API servesThe TypeSpec code for this model.
/** A 200 response listing the protocol versions an API serves * * Discovery sits outside version selection, so unlike `OkT<T>` this response * carries no version headers: neither `CG-Version-Served` nor `Vary`. */@doc("A 200 response listing the protocol versions an API serves")@Versioning.added(CommonGrants.Versions.v0_6)model VersionDiscoveryResponse extends Success { /** The protocol versions the API serves */ data: Models.VersionDiscovery;}Changelog
Section titled “Changelog”| Version | Changes | Schema |
|---|---|---|
| 0.6.0 |
| VersionDiscoveryResponse.yaml |
Created
Section titled “Created”A 201 response with data.
| Parameter | Type | Description |
|---|---|---|
| status | integer | The HTTP status code |
| message | string | The message to return |
| data | any | The data to return |
Formats
Section titled “Formats”A JSON example of this model.
{ "status": 201, "message": "Created", "data": { "id": "123", "name": "Test 1" }}The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: Created.yamltype: objectproperties: data: description: Response datarequired: - dataallOf: - $ref: Success.yamlunevaluatedProperties: not: {}description: A 201 response with dataThe TypeSpec code for this model.
/** A 201 response with data of an unspecified shape * * Routes use the typed `CreatedT<T>` variant. */@doc("A 201 response with data")@Versioning.added(CommonGrants.Versions.v0_1)model Created extends Success { /** Response data */ data: unknown;}Use the CreatedT<T> template to define a 201 response with typed data within an API operation:
import "@common-grants/core";import "@typespec/http";
using TypeSpec.Http;using CommonGrants.Responses;
model TestModel { id: string; name: string;}
@summary("Create test")@doc("Create a test model")@postop createTest(@body body: TestModel): CreatedT<TestModel>;Changelog
Section titled “Changelog”| Version | Changes | Schema |
|---|---|---|
| 0.1.0 |
| Created.yaml |
Accepted
Section titled “Accepted”A 202 response with data.
Returned when a request is accepted for processing but may not be applied immediately, such as a change submitted for review. The typed AcceptedT<T> variant also sets a Location header that points to the accepted resource when one is available.
| Parameter | Type | Description |
|---|---|---|
| status | integer | The HTTP status code |
| message | string | The message to return |
| data | any | The data to return |
Formats
Section titled “Formats”A JSON example of this model.
{ "status": 202, "message": "Accepted", "data": { "id": "123", "name": "Test 1" }}The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: Accepted.yamltype: objectproperties: data: description: Response datarequired: - dataallOf: - $ref: Success.yamlunevaluatedProperties: not: {}description: A 202 response with dataThe TypeSpec code for this model.
/** A 202 response with data of an unspecified shape * * Routes use the typed `AcceptedT<T>` variant. */@doc("A 202 response with data")@Versioning.added(CommonGrants.Versions.v0_4)model Accepted extends Success { /** Response data */ data: unknown;}Use the AcceptedT<T> template to define a 202 response with typed data within an API operation:
import "@common-grants/core";import "@typespec/http";
using TypeSpec.Http;using CommonGrants.Responses;
model TestModel { id: string; name: string;}
@summary("Submit test")@doc("Submit a test model for processing")@postop submitTest(@body body: TestModel): AcceptedT<TestModel>;Changelog
Section titled “Changelog”| Version | Changes | Schema |
|---|---|---|
| 0.4.0 |
| Accepted.yaml |