Introduction
In JFrog Artifactory, the ability to create and manage repositories depends on your role:
- Platform Admin: Can create new repositories and assign existing resources to projects.
- Project Admin: Can create new repositories only for the project(s) they administer.
This article shows how a Project Admin can create a new project-scoped repository via the Artifactory REST API.
Important Note
-
Include the Project Key in the Repository Name
-
When creating project-scoped repositories, the repository’s name must begin with the project key—for example, <PROJECT_KEY>-<REPOSITORY_KEY>. This ensures the repository is recognized as belonging to that project.
-
-
Use a Token with Project Admin Permissions
-
Your Authorization header must include a token belonging to a user who has the Project Admin role on the specified project.
-
-
Set the projectKey Property
-
In addition to having the project key in the repository name, you must also include "projectKey": "<PROJECT_KEY>" in the JSON payload.
-
REST API Endpoint Use the following PUT request to create a repository. Replace the placeholders with the appropriate values:
Parameters
- <PROJECT_ADMIN_TOKEN> – Authentication token for the Project Admin.
- <ART_URL> – Your Artifactory base URL.
- <PROJECT_KEY> – The key of the project.
- <REPOSITORY_KEY> – The repository key (name)
- <REPO_TYPE> – Repository class (local, remote, or virtual).
- <PACKAGE_TYPE> – Type of package (maven, docker, npm, etc.).
- <DESCRIPTION> – A brief description of the repository.
curl -H "Authorization: Bearer <PROJECT_ADMIN_TOKEN>" \ -X PUT "https://<ART_URL>/artifactory/api/repositories/<PROJECT_KEY>-<REPOSITORY_KEY>" \ -H "Content-Type: application/json" \ --data '{ "rclass": "<REPO_CLASS>", // e.g., local, remote, virtual "packageType": "<PACKAGE_TYPE>", // e.g., docker, maven, npm, etc. "description": "<DESCRIPTION>", "projectKey": "<PROJECT_KEY>" }'
Example Usage
Below is a real-world example of creating a local Docker repository for project key test. In this example:
- rclass is local
- packageType is docker
- The repository key (name) is test-docker-dev-local
- The project key in both the name and JSON payload is test
curl -H "Authorization: Bearer $TOKEN" \ -X PUT "https://$ART_URL.jfrog.io/artifactory/api/repositories/test-docker-dev-local" \ -H "Content-Type: application/json" \ --data '{ "rclass": "local", "packageType": "docker", "description": "Local Docker repository for project test", "projectKey": "test" }'
Response:Successfully created repository 'test-docker-dev-local'
Verifying Your Repository
-
Artifactory UI: In your Artifactory instance, navigate to the relevant project. You should see the newly created repository listed.
-
Get Status of Project Repository REST API
-
Run a GET ${baseUrl}/v1/projects/_/repositories/{repo_name} to confirm that your new repository appears in the response.
-
Please note this REST API requires a user to have an 'Administer Platform' role.
-
Summary
By including the project key in both the repository name and the JSON payload, and ensuring you use credentials with the Project Admin role, you can successfully create a project-scoped repository in JFrog Artifactory via the REST API.
If you have any issues or need further assistance, refer to JFrog’s official documentation or contact JFrog Support.