REST Endpoints
REST declarations define endpoint metadata in IDL so service/client contracts stay consistent.
Basic Syntax
Use rest followed by an identifier and a property block.
contractor
rest SignInWithEmail {
path: "/api/v1/auth/sign-in/email"
method: "POST"
}Properties
Supported properties:
path(required): string literalmethod(required): string literal, one ofGET,POST,PUT,PATCH,DELETE(case-insensitive)queries(optional): array literal of stringsrequestBody(optional): user-defined type orNullresponseBody(optional): user-defined type orNull
Type checker notes:
methodandpathare required.requestBodyandresponseBodydo not accept primitive built-in types.GETwith non-nullrequestBodyis allowed but emits a warning.- Unknown or duplicate properties are rejected.
Example
contractor
rest GetProfile {
path: "/api/v1/auth/profile"
method: "GET"
queries: ["includeRoles"]
responseBody: ProfileResponse
}
rest SignInWithEmail {
path: "/api/v1/auth/sign-in/email"
method: "POST"
requestBody: SignInWithEmailRequest
responseBody: SignInResponse
}Common Mistakes
- Using
request/responseinstead ofrequestBody/responseBody. - Using non-string values inside
queries. - Supplying built-in primitive type directly to
requestBodyorresponseBody.