Add repositories with Swimm's API
If you have a large number of repositories, use our Add Repo API to add repositories in bulk.
Navigate to your workspace settings to generate an API Key.
![Add Repository as non-admin](/img/settings/workspace/workspace-settings-swimm-api-key-bg.png)
Note: Please reach out to your Swimm representative to enable API Keys for your workspace.
Send a POST request
Use the following details:
Type | Key | Value |
---|---|---|
URL | - | https://app.swimm.io/api |
Header | x-swimm-api-key | Your Swimm API Key |
Header | Content-Type | application/json |
Body | workspaceId | Your Swimm workspace ID |
Body | requestName | AddRepositoryToWorkspaceRequestV1 |
Body | gitUrl | URL of your Git repository to add |
Example cURL Request
curl -X POST https://app.swimm.io/api \
-H "x-swimm-api-key: SWIMM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"requestName": "AddRepositoryToWorkspaceRequestV1",
"gitUrl": "URL_OF_YOUR_GIT_REPOSITORY",
"workspaceId": "SWIMM_WORKSPACE_ID"
}'
Post-Request Steps
After calling the API, follow these steps to ensure successful integration:
1. Validate the Response
Ensure the API response matches the expected format:
{
"repoId": "YOUR_SWIMM_REPO_ID",
"swimmJson": {
"repo_id": "YOUR_SWIMM_REPO_ID"
}
}
2. Commit the swimmJson Property
Save the swimmJson
property content into your repository at the path .swm/swimm.json
.
3. Merge and Push
Merge and push the .swm/swimm.json
file to the branches you want to work with Swimm.