# POST /admin/securityprofiles

> Add a security profile with a name, expiry date, client credentials grant type and client ID, secret and redirect URIs; DS Server returns the new profile's ID.

- **Product:** DS Server
- **Section:** Documentation
- **Kind:** Endpoint
- **Path:** DS Server > API Reference > Web API > Administration > /securityprofiles > POST /admin/securityprofiles
- **1125 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/web-api/administration/securityprofiles/post/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/web-api/administration/securityprofiles/post/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/web-api/administration/securityprofiles/post/llms-full.txt

---

`POST` `https://example.com/admin/securityprofiles`

### Description

Adds a new security profile.

### Examples

The following example adds a new security profile with the given information. `allowClientCredentialsGrantType` belongs to the security profile, not to `clientCredentials`: inside `clientCredentials`, DS Server ignores it.

```bash
# Request:
curl --location --request POST 'https://trial.dsserver.io/admin/securityprofiles' \
    --header 'Authorization: Basic YWRtaW46YWRtaW5hZG1pbg==' \
    --header 'Content-Type: application/json' \
    --data-raw '{
            "name": "My security profile",
            "allowClientCredentialsGrantType": false,
            "clientCredentials": {
                "id": "GHGGHGD6766",
                "secret": "GHZUZW441543HJUKUU",
                "authorizedRedirectUris": [
                    "https://trial.dsserver.io/oauth/redirect"
                ]
            }
        }'

# Result:
7
```

The following example adds a security profile with a name only. DS Server generates the client ID and the client secret, which [GET /admin/securityprofiles/{id}](https://docs.textcontrol.com/ds-server/reference/web-api/administration/securityprofiles-id/get/llms-full.txt) returns.

```bash
# Request:
curl --location --request POST 'https://trial.dsserver.io/admin/securityprofiles' \
    --header 'Authorization: Basic YWRtaW46YWRtaW5hZG1pbg==' \
    --header 'Content-Type: application/json' \
    --data-raw '{ "name": "My security profile" }'

# Result:
8
```

### Authorization

This endpoint supports the Basic authorization method:

#### Basic

| Header field | Description |
|---|---|
| Authorization | The username "admin" and your admin password are combined into a string separated by a colon, e.g.: admin:password. The resulting string is encoded using the RFC2045-MIME variant of Base64, except not limited to 76 char/line. The authorization method and a space i.e. "Basic " is then put before the encoded string. For example: `Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l` |

### Request Payload

| Type | Value |
|---|---|
| SecurityProfile | The SecurityProfile object contains information about the security profile. |

#### SecurityProfile

| Name | Type | Value | Optional |
|---|---|---|---|
| name | String | A user friendly name for the security profile. | yes |
| allowClientCredentialsGrantType | Boolean | Specifies whether the client credentials grant type is activated or not. | yes |
| expiryDate | DateTime | An expiry date for the security profile, for example `"2027-06-30T00:00:00"`. A date without a time zone offset is taken as the local time of the server. When omitted, the security profile doesn't expire. | yes |
| clientCredentials | ClientCredentials | The ClientCredentials object contains OAuth client credentials for the security profile. When omitted, DS Server generates a client ID and a client secret. | yes |

#### ClientCredentials

| Name | Type | Value | Optional |
|---|---|---|---|
| id | String | The client ID of the security profile. When omitted, DS Server generates one. | yes |
| secret | String | The client secret of the security profile. When omitted, DS Server generates one. | yes |
| authorizedRedirectUris | String\[\] | An array of authorized redirect URIs. | yes |

### Success Response

| Status | Description |
|---|---|
| 200 | On success, the HTTP status code in the response header is 200 (OK). The return value is the new ID of the added security profile. |

### Error Response

| Status | Description |
|---|---|
| 401 | A 401 (Unauthorized) is returned, if the user is not authorized. |
| 400 | A 400 (Bad Request) is returned, if the given client ID exists already. The body is the JSON string "A profile with the given client ID already exists." |
| 400 | A 400 (Bad Request) is returned, if the body is missing or isn't valid JSON. The body is the JSON string "Requst body cannot be empty." (spelled this way by DS Server). |
| 415 | A 415 (Unsupported Media Type) is returned, if the `Content-Type` header isn't `application/json`. |

---

## Nearby

- **Previous:** [GET /admin/securityprofiles](https://docs.textcontrol.com/ds-server/reference/web-api/administration/securityprofiles/get/llms-full.txt)
- **Next:** [/admin/securityprofiles/{id}](https://docs.textcontrol.com/ds-server/reference/web-api/administration/securityprofiles-id/llms-full.txt)
