---
title: "Add a deploy key for a project"
method: POST
path: "/api/v4/projects/{id}/deploy_keys"
tags: ["deploy_resources"]
---

# Add a deploy key for a project

`POST /api/v4/projects/{id}/deploy_keys`

## Request

- Base URL: `https://gitlab.com`
- URL: `https://gitlab.com/api/v4/projects/{id}/deploy_keys`
- Auth: none declared

Adds a deploy key for a specified project. If the deploy key already exists in another project, it is joined to the current project only if the original one is accessible by the same user.

## Path parameters

- `id` string, required

## Request body

- PostApiV4ProjectsIdDeployKeys: Add a deploy key for a project
  - `key` string, required: New deploy key
  - `title` string, required: New deploy key's title
  - `can_push` boolean: Can deploy key push to the project's repository
  - `expires_at` string, date-time: The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)

## Response `201`

Add a deploy key for a project

- APIEntitiesDeployKeysProject: API_Entities_DeployKeysProject model
  - `id` integer, required
  - `title` string, required
  - `created_at` string, date-time, required
  - `expires_at` string, date-time, required
  - `last_used_at` string, date-time, required
  - `key` string, required
  - `usage_type` string, required
  - `fingerprint` string
  - `fingerprint_sha256` string, required
  - `projects_with_write_access` APIEntitiesProjectIdentity
    - `id` integer, required
    - `description` string, required
    - `name` string, required
    - `name_with_namespace` string, required
    - `path` string, required
    - `path_with_namespace` string, required
    - `created_at` string, date-time, required
  - `projects_with_readonly_access` APIEntitiesProjectIdentity
    - `id` integer, required
    - `description` string, required
    - `name` string, required
    - `name_with_namespace` string, required
    - `path` string, required
    - `path_with_namespace` string, required
    - `created_at` string, date-time, required
  - `can_push` boolean, required

## Other responses

- `400`: Bad request
- `401`: Unauthorized
- `404`: Not found

---

[API](https://skmtc.dev/gitlab/apis/gitlab-api.md) - [All operations](https://skmtc.dev/gitlab/apis/gitlab-api/llms.txt) - [OpenAPI document](https://skmtc.dev/gitlab/apis/gitlab-api/revisions/b234947ef3f2?raw)
