Skip to content

Success

Base model for all successful responses.

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

A JSON example of this model.

{
"status": 200,
"message": "Success"
}
VersionChangesSchema
0.1.0
  • Added Success model
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

A JSON example of this model.

{
"status": 200,
"message": "Success",
"data": {
"id": "123",
"name": "Test 1"
}
}

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")
@get
op getTest(): OkT<TestModel>;
VersionChangesSchema
0.1.0
  • Added Ok model
Ok.yaml

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

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"
}
VersionChangesSchema
0.6.0
  • Added VersionDiscoveryResponse model
VersionDiscoveryResponse.yaml

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

A JSON example of this model.

{
"status": 201,
"message": "Created",
"data": {
"id": "123",
"name": "Test 1"
}
}

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")
@post
op createTest(@body body: TestModel): CreatedT<TestModel>;
VersionChangesSchema
0.1.0
  • Added Created model
Created.yaml

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

A JSON example of this model.

{
"status": 202,
"message": "Accepted",
"data": {
"id": "123",
"name": "Test 1"
}
}

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")
@post
op submitTest(@body body: TestModel): AcceptedT<TestModel>;
VersionChangesSchema
0.4.0
  • Added Accepted model
Accepted.yaml