# Check permissions for specified entities

`POST /api/2/checkPermissions`

This endpoint allows you to verify permissions for various entities on specific resources.

Authentication (security requirement alternatives):

```json
[
  {
    "OpenIDConnect": []
  },
  {
    "NginxBasic": []
  },
  {
    "Bearer": []
  }
]
```

- OpenIDConnect: openIdConnect. OpenID Connect Discovery URL. The placeholder is replaced by Swagger UI when configured.
- NginxBasic: http (basic). Eclipse Ditto sandbox demo user (demo1 ... demo9) + password (demo)
- Bearer: http (bearer). A JSON Web Token issued by a supported OAuth 2.0 Identity Provider.

Request body: application/json (required)

JSON object containing permission check requests, keyed by an arbitrary identifier.

Type: object

Request to check permissions for various entities and resources.

Additional properties: 
  Type: object
  
  Details for a specific permission check request.
  
  - `resource` (optional)
    Type: string
    
    Resource path the permission check applies to.
  
  - `entityId` (optional)
    Type: string
    
    thingId of the entity performing the action.
  
  - `hasPermissions` (optional)
    Type: Array<string>
    
    Required permissions on the resource.
    
    Items:
      Type: string
      
      enum: ["READ","WRITE"]

Responses:

- 200: Response with permission check results for each entity.

Content type: application/json

Type: object

Response with permission check results for each entity.

Additional properties: 
  Type: boolean

- 401: Unauthorized request due to missing authentication.

Content type: application/json

Type: AdvancedError

Schema: [AdvancedError](https://sourcey-ditto.pages.dev/http-api-doc/models/advancederror.md)

- `status` (required)
  Type: integer
  
  The HTTP status of the error

- `error` (required)
  Type: string
  
  The error code of the occurred exception

- `message` (required)
  Type: string
  
  The message of the error - what went wrong

- `description` (optional)
  Type: string
  
  A description how to fix the error or more details

- `href` (optional)
  Type: string
  
  A link to further information about the error and how to fix it

## Examples

### cURL

```bash
curl -X POST 'https://ditto.eclipseprojects.io/api/2/checkPermissions' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{}'
```

### JavaScript

```javascript
const response = await fetch('https://ditto.eclipseprojects.io/api/2/checkPermissions', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body: '{}',
});

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

### Python

```python
import requests

response = requests.post(
    'https://ditto.eclipseprojects.io/api/2/checkPermissions',
    data='{}'.encode('utf-8'),
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
