> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gobl.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Sign a GOBL document

> Builds the document, wraps it in an envelope, and signs it with the provided private key.



## OpenAPI

````yaml /openapi/v0.json post /sign
openapi: 3.1.0
info:
  title: GOBL API
  description: >-
    Go Business Language — build, validate, sign, and query tax-aware business
    documents.
  version: v0
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  contact:
    name: Invopop
    url: https://gobl.org
servers:
  - url: https://gobl.dev/v0
    description: Production
  - url: /v0
    description: Local
security: []
tags:
  - name: Documents
    description: Build, validate, correct, and replicate GOBL documents.
  - name: Signing
    description: Sign and verify GOBL envelopes.
  - name: Reference
    description: JSON schemas, tax regimes, and format addons.
  - name: Meta
    description: Service metadata.
paths:
  /sign:
    post:
      tags:
        - Signing
      summary: Sign a GOBL document
      description: >-
        Builds the document, wraps it in an envelope, and signs it with the
        provided private key.
      operationId: sign
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SignRequest'
      responses:
        '200':
          description: Signed envelope
          content:
            application/json:
              schema: {}
        '400':
          $ref: '#/components/responses/Error'
        '422':
          $ref: '#/components/responses/Error'
components:
  schemas:
    SignRequest:
      type: object
      required:
        - data
      properties:
        data:
          description: GOBL document to sign.
        template:
          description: Optional template to merge with the data before signing.
        privatekey:
          $ref: '#/components/schemas/JWK'
          description: ES256 private key in JWK format.
        type:
          type: string
          description: Document type hint.
        envelop:
          type: boolean
          description: Wrap in envelope (always true for signing).
          default: true
    JWK:
      type: object
      description: JSON Web Key (RFC 7517) — ES256 / P-256.
      properties:
        kty:
          type: string
          example: EC
        crv:
          type: string
          example: P-256
        alg:
          type: string
          example: ES256
        use:
          type: string
          example: sig
        kid:
          type: string
          format: uuid
        x:
          type: string
          description: Base64url-encoded X coordinate.
        'y':
          type: string
          description: Base64url-encoded Y coordinate.
        d:
          type: string
          description: Base64url-encoded private exponent (private keys only).
    Error:
      type: object
      properties:
        code:
          type: integer
          description: HTTP status code.
          example: 422
        key:
          type: string
          description: Machine-readable error key.
        message:
          type: string
          description: Human-readable message.
        faults:
          type: array
          description: Validation faults.
          items:
            type: object
            properties:
              properties:
                type: array
                items:
                  type: string
                description: Property paths that failed.
              description:
                type: string
  responses:
    Error:
      description: Error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'

````