# Add Project

This API allows users to add one or more projects for Adhoc scanning.

### Authentication

Addition of project is subject to user roles and permissions.&#x20;

**Method**: Bearer Token or API Key

**Details**: For bearer token header name should be `X-OpsMx-Auth`. API keys can be generated from the SSD UI.&#x20;

### Request Details

#### Endpoint URL

| **Method** | **URL Path**                             |
| ---------- | ---------------------------------------- |
| POST       | {host}/ssdservice/v1/scan/project/upload |

#### Request Headers

| **Header**   | **Description**                 |
| ------------ | ------------------------------- |
| Content-Type | application/json                |
| X-OpsMx-Auth | Bearer Token for authentication |

#### Request Params

| **Header** | **Description**                   | **Comment**                                                                                                                                  |
| ---------- | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| orgId      | ID of current organisation of ssd | <p><br></p>                                                                                                                                  |
| teamId     | Comma separated teamIds           | The team id will be checked for user permissions. In case user does not have proper  permission to any team, project addition will be denied |

### CURL Example

{% code overflow="wrap" %}

```
curl --location --globoff '{host}/ssdservice/v1/scan/project/upload?orgId=bbcd3005-5a94-4ab8-a42d-449bb11e78a9&teamId=6d226f5a-605d-41d5-8fed-e32e91213b6f' \
--header 'X-OpsMx-Auth: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '[
    {
        "name": "test-git-1",
        "scanType": "sourceScan",
        "platform": "github",
        "accountName": "github-prabhu (stage)",
        "teamName": "stage",
        "scanLevel": "repoLevel",
        "organisation": "PrabhuQA",
        "type": "user",
        "projectConfigs": [
            {
                "repository": "audit-service",
                "scheduleTime": 0,
                "branch": [
                    "onlyMain"
                ],
                "branchPattern": "",
                "scanUpto": 0
            }
        ]
    }
]'
```

{% endcode %}

#### Request Body (JSON)

```
[
    {
        "name": "test-git-1",
        "scanType": "sourceScan",
        "platform": "github",
        "accountName": "github-prabhu (stage)",
        "teamName": "stage",
        "scanLevel": "repoLevel",
        "organisation": "PrabhuQA",
        "type": "user",
        "projectConfigs": [
            {
                "repository": "audit-service",
                "scheduleTime": 0,
                "branch": [
                    "onlyMain"
                ],
                "branchPattern": "",
                "scanUpto": 0
            }
        ]
    }
]
```

#### Request Body (Artifact)

```
[
  {
    "name": "sample-docker-artifact-project",
    "scanType": "artifactScan",
    "platform": "docker",
    "accountName": "test",
    "teamName": "test",
    "scanLevel": "repoLevel",
    "organisation": "opsmx11",
    "type": "",
    "projectConfigs": [
      {
        "repository": "restapp",
        "scheduleTime": 0,
        "tag": [
          "simple-restapp-17412"
        ],
        "tagPattern": "",
        "scanUpto": 0
      }
    ]
  }
]
```

### Response Details

#### Success Response (Status Code: 200/201)

```
{
    "project1": "Succesfully Created!",
    "project2": "Succesfully Created!"
}
```

### Error Responses

| **Status Code** | **Description**                                             | **Example Error Response**            |
| --------------- | ----------------------------------------------------------- | ------------------------------------- |
| 400             | Bad Request (Invalid parameters or missing required fields) | {"error": "Invalid input data."}      |
| 401             | Unauthorized (Missing or invalid authentication token)      | {"error": "Authentication required."} |
| 500             | Some issues in Server                                       | {"error": "Resource not found."}      |

<br>
