Create Repository
Required permissions : Workspace Admin or System Admin
Creating a repository is split into three different APIs for each type: local, remote, and virtual.
Local Repository
-
Endpoint:
https://api.repoflow.io/:workspaceId/repositories/local
-
Method: POST
-
Data:
name
: The name of the repository (must be 2-30 characters, only lowercase English letters, numbers, and dashes allowed)packageType
: The type of packages the repository will store (e.g., npm, PyPI, Maven, NuGet, Docker)
Example:
{
"name": "my-local-repo",
"packageType": "npm"
}
Remote Repository
-
Endpoint:
https://api.repoflow.io/:workspaceId/repositories/remote
-
Method: POST
-
Data:
name
: The name of the repository (must be 2-30 characters, only English letters, numbers, and dashes allowed)packageType
: The type of packages the repository will store (e.g., npm, PyPI, Maven, NuGet, Docker)remoteRepositoryUrl
: The URL of the remote repositoryremoteRepositoryUsername
(optional): The username for accessing the remote repositoryremoteRepositoryPassword
(optional): The password for accessing the remote repositoryisRemoteCacheEnabled
: A boolean indicating if caching is enabled for the remote repositoryfileCacheTimeTillRevalidation
(optional): The number of milliseconds before a regular file in the cache requires revalidation, send null for indefinite caching.metadataCacheTimeTillRevalidation
(optional): The number of milliseconds before a metadata file in the cache requires revalidation, send null for indefinite caching. Metadata files typically include listings of package names or versions.
Example:
{
"name": "my-remote-repo",
"packageType": "npm",
"remoteRepositoryUrl": "https://registry.npmjs.org",
"remoteRepositoryUsername": "user",
"remoteRepositoryPassword": "password",
"isRemoteCacheEnabled": true,
"fileCacheTimeTillRevalidation": 345600000, // 4 days in milliseconds
"metadataCacheTimeTillRevalidation": 86400000 // 1 day in milliseconds
}
Virtual Repository
-
Endpoint:
https://api.repoflow.io/:workspaceId/repositories/virtual
-
Method: POST
-
Data:
name
: The name of the repository (must be 2-30 characters, only English letters, numbers, and dashes allowed)packageType
: The type of packages the repository will store (e.g., npm, PyPI, Maven, NuGet, Docker)childRepositoryIds
: An array of repository IDs to be included in the virtual repositoryuploadLocalRepositoryId
(optional): The ID of a local repository where uploads will be stored. This ID must also be included inchildRepositoryIds
.
Example:
{
"name": "my-virtual-repo",
"packageType": "npm",
"childRepositoryIds": ["repo-id-1", "repo-id-2"],
"uploadLocalRepositoryId": "repo-id-1" // optional
}
Error Handling
If an error occurs, the API will return a status code and a message describing the error. Common errors include:
- 400 Bad Request: The request data is invalid or incomplete.
- 401 Unauthorized: The user does not have the required permissions.
- 404 Not Found: The specified repository or workspace does not exist.
- 500 Internal Server Error: An unexpected error occurred on the server.
Example Usage
Here's an example of how to use the API to create a local repository using curl
:
curl -X POST https://api.repoflow.io/:workspaceId/repositories/local \
-H "Content-Type: application/json" \
-d '{
"name": "my-local-repo",
"packageType": "npm"
}'