# Push resource files to a repository

`POST https://api.lingohub.com/v1/{workspaceUrl}/projects/{projectUrl}/push`

LingoHub API V1 · [Repository](https://developers.lingohub.com/reference/v1/operations/tags/repository.md) · operation `v1RepositoryPushFiles`

Triggers pushing the project's resource files to the linked repository. A repository connection (e.g. GitHub, GitLab, Bitbucket, or Azure DevOps) must have been configured for the project beforehand. The push can be performed either as a direct commit or as a pull/merge request depending on the configuration or the explicit pushType parameter.

## Parameters

| Parameter | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `workspaceUrl` | path | yes | string | workspaceUrl |
| `projectUrl` | path | yes | string | projectUrl |

## Example request

```sh
curl --request POST \
  --url https://api.lingohub.com/v1/WORKSPACE_URL/projects/PROJECT_URL/push \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "branch": "main",
  "commitMessage": "Update translations for release 2.3.0",
  "commitDescription": "Includes updated French and German translations",
  "path": "/src/config/locales",
  "languageCode": "en",
  "pullRequestBranch": "lingohub/update-translations",
  "pullRequestTitle": "Update translations",
  "pullRequestDescription": "This PR updates the translation files exported from LingoHub."
}'
```

## Responses

- `200`: Successfully triggered the push operation. Returns an empty body.
- `400`: Bad Request: The project has no linked repository or the push parameters are invalid.
- `401`: Unauthorized: Authentication credentials are missing or invalid.
- `403`: Forbidden: The authenticated user does not have resource management permission on this project.
- `404`: Not Found: The specified workspace or project does not exist.
- `422`: Unprocessable Entity: The branch does not exist in the repository, or the project has no language with the given languageCode.

## OpenAPI definition

The complete definition of this operation, with every schema it references:

````json
{
  "openapi": "3.1.0",
  "info": {
    "title": "LingoHub API V1",
    "version": "1"
  },
  "servers": [
    {
      "url": "https://api.lingohub.com",
      "description": "Generated server url"
    }
  ],
  "tags": [
    {
      "name": "Repository",
      "description": "Endpoint to push resource files to a repository"
    }
  ],
  "paths": {
    "/v1/{workspaceUrl}/projects/{projectUrl}/push": {
      "post": {
        "tags": [
          "Repository"
        ],
        "summary": "Push resource files to a repository",
        "description": "Triggers pushing the project's resource files to the linked repository. A repository connection (e.g. GitHub, GitLab, Bitbucket, or Azure DevOps) must have been configured for the project beforehand. The push can be performed either as a direct commit or as a pull/merge request depending on the configuration or the explicit pushType parameter.",
        "operationId": "v1RepositoryPushFiles",
        "parameters": [
          {
            "name": "workspaceUrl",
            "in": "path",
            "description": "workspaceUrl",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "projectUrl",
            "in": "path",
            "description": "projectUrl",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PushFilesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successfully triggered the push operation. Returns an empty body."
          },
          "400": {
            "description": "Bad Request: The project has no linked repository or the push parameters are invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V1ErrorInfo"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized: Authentication credentials are missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V1ErrorInfo"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden: The authenticated user does not have resource management permission on this project.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V1ErrorInfo"
                }
              }
            }
          },
          "404": {
            "description": "Not Found: The specified workspace or project does not exist.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V1ErrorInfo"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity: The branch does not exist in the repository, or the project has no language with the given languageCode.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "PushFilesRequest": {
        "type": "object",
        "description": "The information needed to perform the push operation",
        "properties": {
          "branch": {
            "type": "string",
            "description": "Name of the branch to push to. If left empty, the default branch configured in the repository connection will be used.",
            "example": "main"
          },
          "pushType": {
            "$ref": "#/components/schemas/PushType",
            "description": "The type of push to perform: PUSH for a direct commit, or PULL_REQUEST for creating a pull/merge request. If left empty, the project's default push type will be used.",
            "enum": [
              "PUSH",
              "PULL_REQUEST"
            ]
          },
          "commitMessage": {
            "type": "string",
            "description": "The commit message for the push. If left empty, a default commit message will be generated.",
            "example": "Update translations for release 2.3.0"
          },
          "commitDescription": {
            "type": "string",
            "description": "An optional extended commit description providing additional context for the push.",
            "example": "Includes updated French and German translations"
          },
          "path": {
            "type": "string",
            "description": "Restrict the push to resource files under this path. If not set, all resource files of the project will be pushed.",
            "example": "/src/config/locales"
          },
          "languageCode": {
            "type": "string",
            "description": "Restrict the push to resource files of this locale. Specified as an ISO 639-1 code (e.g. 'en', 'de-AT') and matched against the project's languages ignoring case, so 'de-at' selects 'de-AT'. A code the project has no language for is rejected.",
            "example": "en"
          },
          "pullRequestBranch": {
            "type": "string",
            "description": "Name of the branch to create for the pull/merge request. Only applicable when pushType is PULL_REQUEST.",
            "example": "lingohub/update-translations"
          },
          "pullRequestTitle": {
            "type": "string",
            "description": "The title of the pull/merge request. Only applicable when pushType is PULL_REQUEST.",
            "example": "Update translations"
          },
          "pullRequestDescription": {
            "type": "string",
            "description": "The description body of the pull/merge request. Only applicable when pushType is PULL_REQUEST.",
            "example": "This PR updates the translation files exported from LingoHub."
          }
        }
      },
      "PushType": {
        "type": "string",
        "enum": [
          "PUSH",
          "PULL_REQUEST"
        ]
      },
      "V1ErrorInfo": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "text": {
            "type": "string"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "$ref": "#/components/schemas/ErrorDetails"
          },
          "validationErrors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            }
          }
        }
      },
      "ErrorDetails": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/HttpStatus"
          }
        }
      },
      "HttpStatus": {
        "allOf": [
          {
            "$ref": "#/components/schemas/HttpStatusCode"
          }
        ]
      },
      "HttpStatusCode": {
        "type": "object",
        "properties": {
          "error": {
            "type": "boolean"
          },
          "is4xxClientError": {
            "type": "boolean"
          },
          "is5xxServerError": {
            "type": "boolean"
          },
          "is1xxInformational": {
            "type": "boolean"
          },
          "is2xxSuccessful": {
            "type": "boolean"
          },
          "is3xxRedirection": {
            "type": "boolean"
          }
        }
      },
      "ValidationError": {
        "type": "object",
        "properties": {
          "field": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FieldValidationError"
            }
          }
        }
      },
      "FieldValidationError": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "parameters": {
            "type": "object",
            "additionalProperties": {}
          }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "description": "API key authentication. Create API keys in your LingoHub workspace settings. Keys use the `lh-api_` prefix. Pass the full key as the Bearer token.",
        "scheme": "bearer"
      }
    }
  }
}
````
