2020-10-24 23:57:45 +05:30
---
stage: Create
group: Source Code
2021-02-22 17:27:13 +05:30
info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments"
2020-10-24 23:57:45 +05:30
type: reference, api
---
2021-03-11 19:13:27 +05:30
# Repository submodules API **(FREE)**
2018-12-13 13:39:08 +05:30
2020-06-23 00:09:42 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/41213) in GitLab 11.5
2018-12-13 13:39:08 +05:30
## Update existing submodule reference in repository
In some workflows, especially automated ones, it can be useful to update a
submodule's reference to keep up to date other projects that use it.
This endpoint allows you to update a [Git submodule ](https://git-scm.com/book/en/v2/Git-Tools-Submodules ) reference in a
specific branch.
2020-04-08 14:13:33 +05:30
```plaintext
2018-12-13 13:39:08 +05:30
PUT /projects/:id/repository/submodules/:submodule
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
2020-11-24 15:15:51 +05:30
| `submodule` | string | yes | URL-encoded full path to the submodule. For example, `lib%2Fclass%2Erb` |
2018-12-13 13:39:08 +05:30
| `branch` | string | yes | Name of the branch to commit into |
| `commit_sha` | string | yes | Full commit SHA to update the submodule to |
2021-04-17 20:07:23 +05:30
| `commit_message` | string | no | Commit message. If no message is provided, a default is set |
2018-12-13 13:39:08 +05:30
2020-03-13 15:44:24 +05:30
```shell
2020-11-24 15:15:51 +05:30
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/5/repository/submodules/lib%2Fmodules%2Fexample" \
2018-12-13 13:39:08 +05:30
--data "branch=master& commit_sha=3ddec28ea23acc5caa5d8331a6ecb2a65fc03e88& commit_message=Update submodule reference"
```
Example response:
```json
{
"id": "ed899a2f4b50b4370feeea94676502b42383c746",
"short_id": "ed899a2f4b5",
"title": "Updated submodule example_submodule with oid 3ddec28ea23acc5caa5d8331a6ecb2a65fc03e88",
"author_name": "Dmitriy Zaporozhets",
"author_email": "dzaporozhets@sphereconsultinginc.com",
"committer_name": "Dmitriy Zaporozhets",
"committer_email": "dzaporozhets@sphereconsultinginc.com",
"created_at": "2018-09-20T09:26:24.000-07:00",
"message": "Updated submodule example_submodule with oid 3ddec28ea23acc5caa5d8331a6ecb2a65fc03e88",
"parent_ids": [
"ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
],
"committed_date": "2018-09-20T09:26:24.000-07:00",
2019-09-30 21:07:59 +05:30
"authored_date": "2018-09-20T09:26:24.000-07:00",
2018-12-13 13:39:08 +05:30
"status": null
}
```