# Share

Share devices and groups

## Share device location

`POST /share/device`

Authentication (security requirement alternatives):

```json
[
  {
    "BasicAuth": []
  },
  {
    "ApiKey": []
  }
]
```

- BasicAuth: http (basic)
- ApiKey: http (bearer)

Request body: application/x-www-form-urlencoded (required)

Type: object

- `deviceId` (required)
  Type: integer

- `expiration` (required)
  Type: string, date-time

Responses:

- 200: OK

Content type: text/plain

Type: string

```json
"eyJhbGciOi..."
```

- 403: Sharing is disabled or temporary user

## Examples

### cURL

```bash
curl -X POST 'https://demo.traccar.org/api/share/device' \
  -H 'Authorization: Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  --data-raw 'deviceId=0&expiration=2024-01-15T09%3A30%3A00Z'
```

### JavaScript

```javascript
const response = await fetch('https://demo.traccar.org/api/share/device', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
    'Content-Type': 'application/x-www-form-urlencoded',
  },
  body: 'deviceId=0&expiration=2024-01-15T09%3A30%3A00Z',
});

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

### Python

```python
import requests

response = requests.post(
    'https://demo.traccar.org/api/share/device',
    data='deviceId=0&expiration=2024-01-15T09%3A30%3A00Z'.encode('utf-8'),
    headers={
        'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
        'Content-Type': 'application/x-www-form-urlencoded',
    },
)
print(response.text)
```


## Share group devices

`POST /share/group`

Authentication (security requirement alternatives):

```json
[
  {
    "BasicAuth": []
  },
  {
    "ApiKey": []
  }
]
```

- BasicAuth: http (basic)
- ApiKey: http (bearer)

Request body: application/x-www-form-urlencoded (required)

Type: object

- `groupId` (required)
  Type: integer

- `expiration` (required)
  Type: string, date-time

Responses:

- 200: OK

Content type: text/plain

Type: string

```json
"eyJhbGciOi..."
```

- 403: Sharing is disabled or temporary user

## Examples

### cURL

```bash
curl -X POST 'https://demo.traccar.org/api/share/group' \
  -H 'Authorization: Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  --data-raw 'groupId=0&expiration=2024-01-15T09%3A30%3A00Z'
```

### JavaScript

```javascript
const response = await fetch('https://demo.traccar.org/api/share/group', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
    'Content-Type': 'application/x-www-form-urlencoded',
  },
  body: 'groupId=0&expiration=2024-01-15T09%3A30%3A00Z',
});

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

### Python

```python
import requests

response = requests.post(
    'https://demo.traccar.org/api/share/group',
    data='groupId=0&expiration=2024-01-15T09%3A30%3A00Z'.encode('utf-8'),
    headers={
        'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
        'Content-Type': 'application/x-www-form-urlencoded',
    },
)
print(response.text)
```
