# Create a new JWT for authentication and set a cookie if using HTTP

`POST /api/v1/session`

Authentication: no security requirement declared for this operation.

Request body: application/json (required)

Type: object

SessionCreateRequest is for logging in.

Schema: [sessionSessionCreateRequest](https://sourcey-argocd.pages.dev/api/models/sessionsessioncreaterequest/index.md)

- `password` (optional)
  Type: string

- `token` (optional)
  Type: string

- `username` (optional)
  Type: string

Responses:

- 200: A successful response.

Content type: application/json

Type: object

SessionResponse wraps the created token or returns an empty string if deleted.

Schema: [sessionSessionResponse](https://sourcey-argocd.pages.dev/api/models/sessionsessionresponse/index.md)

- `token` (optional)
  Type: string

- default: An unexpected error response.

Content type: application/json

Type: object

Schema: [runtimeError](https://sourcey-argocd.pages.dev/api/models/runtimeerror/index.md)

- `code` (optional)
  Type: integer, int32

- `details` (optional)
  Type: array
  
  Items:
    Reference: [protobufAny](https://sourcey-argocd.pages.dev/api/models/protobufany/index.md); Type: object

- `error` (optional)
  Type: string

- `message` (optional)
  Type: string

## Examples

### cURL

```bash
curl -X POST 'https://argocd.example.com/api/v1/session' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "password": "string",
  "token": "string",
  "username": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "password": "string",
  "token": "string",
  "username": "string"
}`;

const response = await fetch('https://argocd.example.com/api/v1/session', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "password": "string",
  "token": "string",
  "username": "string"
}'''

response = requests.post(
    'https://argocd.example.com/api/v1/session',
    data=body.encode('utf-8'),
    headers={
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
