{
  "openapi": "3.1.0",
  "info": {
    "title": "Lexique Project Translation API",
    "version": "2026-06-19",
    "summary": "Pull and push project translations from Lexique.",
    "description": "The Lexique API lets project API tokens inspect project sync metadata, pull rendered translation files, and push translation updates. Access requires an active trial or Pro subscription."
  },
  "servers": [
    {
      "url": "https://lexique.app"
    }
  ],
  "security": [
    {
      "projectBearerToken": []
    }
  ],
  "paths": {
    "/api/projects/{id}/meta": {
      "get": {
        "operationId": "getProjectMeta",
        "summary": "Get project sync metadata",
        "parameters": [
          {
            "$ref": "#/components/parameters/ProjectId"
          }
        ],
        "responses": {
          "200": {
            "description": "Project metadata and sync capabilities.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProjectMetaResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/ProjectNotFound"
          }
        }
      }
    },
    "/api/projects/{id}/translations/pull": {
      "get": {
        "operationId": "pullTranslations",
        "summary": "Pull translation entries and rendered files",
        "parameters": [
          {
            "$ref": "#/components/parameters/ProjectId"
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["json", "yaml"],
              "default": "json"
            }
          },
          {
            "name": "locale[]",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "style": "form",
            "explode": true
          },
          {
            "name": "domain[]",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "style": "form",
            "explode": true
          },
          {
            "name": "key[]",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "style": "form",
            "explode": true
          },
          {
            "name": "tag[]",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "style": "form",
            "explode": true
          },
          {
            "name": "match",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "onlyCompleted",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Filtered translation entries and rendered files.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TranslationPullResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/ProjectNotFound"
          },
          "422": {
            "$ref": "#/components/responses/InvalidRequest"
          }
        }
      }
    },
    "/api/projects/{id}/translations/push": {
      "post": {
        "operationId": "pushTranslations",
        "summary": "Push translation updates",
        "parameters": [
          {
            "$ref": "#/components/parameters/ProjectId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TranslationPushRequest"
              },
              "examples": {
                "singleKey": {
                  "value": {
                    "key": "checkout.pay",
                    "locale": "fr",
                    "value": "Payer",
                    "overwrite": true,
                    "createMissing": true
                  }
                },
                "entries": {
                  "value": {
                    "entries": [
                      {
                        "key": "checkout.cancel",
                        "locale": "fr",
                        "value": "Annuler",
                        "tags": ["checkout"]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Push summary.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TranslationPushResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/ProjectNotFound"
          },
          "422": {
            "$ref": "#/components/responses/InvalidRequest"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "projectBearerToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "Project API token shown once when created in Lexique."
      }
    },
    "parameters": {
      "ProjectId": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "integer",
          "minimum": 1
        }
      }
    },
    "schemas": {
      "Project": {
        "type": "object",
        "required": ["id", "name", "defaultLocale", "supportedLocales", "translationAdapter"],
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "defaultLocale": {
            "type": "string"
          },
          "supportedLocales": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "translationAdapter": {
            "type": "string"
          },
          "translationAdapterConfig": {
            "type": "object"
          },
          "syncDefaults": {
            "type": ["object", "null"]
          },
          "syncUnsupportedReason": {
            "type": ["string", "null"]
          }
        }
      },
      "ProjectMetaResponse": {
        "type": "object",
        "required": ["project", "capabilities"],
        "properties": {
          "project": {
            "$ref": "#/components/schemas/Project"
          },
          "capabilities": {
            "type": "object"
          }
        }
      },
      "TranslationPullResponse": {
        "type": "object",
        "required": ["project", "capabilities", "filters", "entries", "files"],
        "properties": {
          "project": {
            "$ref": "#/components/schemas/Project"
          },
          "capabilities": {
            "type": "object",
            "required": ["tagFilterMode"],
            "properties": {
              "tagFilterMode": {
                "type": "string",
                "enum": ["any"]
              }
            },
            "additionalProperties": true
          },
          "filters": {
            "type": "object"
          },
          "entries": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RenderedFile"
            }
          }
        }
      },
      "RenderedFile": {
        "type": "object",
        "required": ["filename", "mimeType", "content"],
        "properties": {
          "locale": {
            "type": ["string", "null"]
          },
          "domain": {
            "type": ["string", "null"]
          },
          "filename": {
            "type": "string"
          },
          "mimeType": {
            "type": "string"
          },
          "content": {
            "type": "string"
          }
        }
      },
      "TranslationPushRequest": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "locale": {
            "type": "string"
          },
          "value": {
            "type": "string"
          },
          "domain": {
            "type": ["string", "null"]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "entries": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["key", "locale", "value"],
              "properties": {
                "key": {
                  "type": "string"
                },
                "locale": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                },
                "domain": {
                  "type": ["string", "null"]
                },
                "tags": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "inputs": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "overwrite": {
            "type": "boolean",
            "default": true
          },
          "createMissing": {
            "type": "boolean",
            "default": true
          },
          "match": {
            "type": ["string", "null"]
          }
        }
      },
      "TranslationPushResponse": {
        "type": "object",
        "required": ["project", "options", "summary"],
        "properties": {
          "project": {
            "$ref": "#/components/schemas/Project"
          },
          "options": {
            "type": "object"
          },
          "summary": {
            "type": "object"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": ["code", "message", "details"],
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "details": {
            "type": "object"
          }
        }
      }
    },
    "responses": {
      "Unauthenticated": {
        "description": "Authentication is required.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "The account needs an active trial or Pro subscription.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "code": "payment_required",
              "message": "Your 14-day trial has expired. Upgrade to Pro to use CLI/API sync.",
              "details": {
                "upgradeUrl": "/account"
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "The token or session cannot access the project or scope.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ProjectNotFound": {
        "description": "Project not found.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "InvalidRequest": {
        "description": "The request payload or query parameters are invalid.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
