Encore Framework API

The Encore Framework API is the in-process declarative API surface developers use inside Encore.ts and Encore.go applications. Endpoints are declared with the api() function (TypeScript) or //encore:api annotation (Go), specifying method, path, expose (public vs internal), auth, and optional sensitive flags. Encore parses the source to derive request/response schemas from TypeScript interfaces or Go structs, enforces runtime validation, and wires up service-to-service calls without manual HTTP plumbing. Raw endpoints, fallback routes, path parameters, query, header, and cookie parameters are all first-class.

OpenAPI Specification

encore-framework-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: Encore Framework API
  version: '1.57'
  description: |
    Conceptual OpenAPI describing the runtime HTTP surface that the Encore framework
    (Encore.ts and Encore.go) exposes for every Encore application. This is not a
    single hosted API — it is the per-application surface generated by the framework
    when an api() / //encore:api declaration is parsed. Real endpoints, paths, and
    schemas are app-specific.
  contact:
    name: Encore
    url: https://encore.dev
  license:
    name: MPL-2.0
    url: https://github.com/encoredev/encore/blob/main/LICENSE
servers:
- url: http://localhost:4000
  description: Local Encore dev server (encore run)
- url: https://staging-{app-id}.encr.app
  description: Encore Cloud staging environment
  variables:
    app-id:
      default: example
- url: https://{app-id}.encr.app
  description: Encore Cloud production environment
  variables:
    app-id:
      default: example
paths:
  /__encore/healthz:
    get:
      operationId: healthCheck
      summary: Health Check
      description: Built-in liveness endpoint exposed by every Encore application for platform-level health probing.
      responses:
        '200':
          description: Application is healthy.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Health'
  /__encore/meta:
    get:
      operationId: getAppMetadata
      summary: Get Application Metadata
      description: Returns metadata describing the running Encore application — services, endpoints, databases, Pub/Sub topics, and cron jobs — as derived from the parsed source.
      responses:
        '200':
          description: Application metadata.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AppMetadata'
  /{service}/{endpoint}:
    parameters:
    - name: service
      in: path
      required: true
      description: The Encore service name (the folder containing encore.service.ts or a Go package with //encore:service).
      schema:
        type: string
    - name: endpoint
      in: path
      required: true
      description: The api() / //encore:api endpoint name within the service.
      schema:
        type: string
    get:
      operationId: invokeEndpointGet
      summary: Invoke An Encore Endpoint
      description: |
        Conceptual route showing how Encore exposes any api() declaration with `expose: true`.
        The real method, path, request schema, and response schema are derived from the developer's
        TypeScript interface or Go struct at build time.
      responses:
        '200':
          description: Endpoint response shaped by the application's declared response type.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EndpointResponse'
        '400':
          description: Validation error — request did not match the declared request schema.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthenticated — endpoint requires auth and no valid auth context was provided.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Health:
      type: object
      required:
      - code
      - message
      properties:
        code:
          type: string
          example: ok
        message:
          type: string
          example: Healthy
    AppMetadata:
      type: object
      properties:
        app_id:
          type: string
          description: Encore application identifier.
        services:
          type: array
          items:
            $ref: '#/components/schemas/Service'
    Service:
      type: object
      properties:
        name:
          type: string
        endpoints:
          type: array
          items:
            $ref: '#/components/schemas/Endpoint'
    Endpoint:
      type: object
      properties:
        name:
          type: string
        method:
          type: string
          description: HTTP method declared in the api() options.
          example: GET
        path:
          type: string
          example: /hello/:name
        expose:
          type: boolean
          description: Whether the endpoint is reachable from outside the Encore application.
        auth:
          type: boolean
          description: Whether Encore requires a valid auth context before invoking the endpoint.
        sensitive:
          type: boolean
          description: Whether Encore should redact request and response payloads in traces.
        raw:
          type: boolean
          description: Whether this is a raw HTTP endpoint declared via api.raw().
    EndpointResponse:
      type: object
      description: Placeholder for the application-specific response shape derived from the declared response type.
      additionalProperties: true
    Error:
      type: object
      required:
      - code
      - message
      properties:
        code:
          type: string
          description: Encore canonical error code (e.g. invalid_argument, unauthenticated, not_found).
          example: invalid_argument
        message:
          type: string
          example: Field "name" must not be empty.
        details:
          type: array
          items:
            type: object
            additionalProperties: true