# Update details of a single playlist.

`PUT /station/{station_id}/playlist/{id}`

Authentication (security requirement alternatives):

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

- ApiKey: apiKey, header X-API-Key

Parameters:

- `station_id` (path, unknown, required)
  Type: unknown
  
  anyOf:
    Type: integer, int64
  
    Type: string, string

- `id` (path, integer, int64, required) - Playlist ID
  Type: integer, int64

Request body: application/json

Type: object

Schema: [StationPlaylist](https://sourcey-azuracast.pages.dev/docs/api/models/stationplaylist/index.md)

allOf:
  Reference: [HasAutoIncrementId](https://sourcey-azuracast.pages.dev/docs/api/models/hasautoincrementid/index.md); Type: object

  Type: object
  
  - `name` (optional)
    Type: string
    
    Example:
    
    ```json
    "Test Playlist"
    ```
  
  - `description` (optional)
    Type: string; nullable
    
    Example:
    
    ```json
    "A playlist containing my favorite songs"
    ```
  
  - `type` (optional)
    Reference: [PlaylistTypes](https://sourcey-azuracast.pages.dev/docs/api/models/playlisttypes/index.md); Type: string
    
    enum: ["default","once_per_x_songs","once_per_x_minutes","once_per_hour","custom"]
  
  - `source` (optional)
    Reference: [PlaylistSources](https://sourcey-azuracast.pages.dev/docs/api/models/playlistsources/index.md); Type: string
    
    enum: ["songs","playlists","remote_url","requests"]
  
  - `order` (optional)
    Reference: [PlaylistOrders](https://sourcey-azuracast.pages.dev/docs/api/models/playlistorders/index.md); Type: string
    
    enum: ["random","shuffle","sequential"]
  
  - `remote_url` (optional)
    Type: string; nullable
    
    Example:
    
    ```json
    "https://remote-url.example.com/stream.mp3"
    ```
  
  - `remote_type` (optional)
    Type: unknown; nullable
    
    Example:
    
    ```json
    "stream"
    ```
    
    oneOf:
      Reference: [PlaylistRemoteTypes](https://sourcey-azuracast.pages.dev/docs/api/models/playlistremotetypes/index.md); Type: string
      
      enum: ["stream","playlist","other"]
  
  - `remote_buffer` (optional)
    Type: integer
    
    The total time (in seconds) that Liquidsoap should buffer remote URL streams.
    
    Example:
    
    ```json
    0
    ```
  
  - `is_enabled` (optional)
    Type: boolean
    
    Example:
    
    ```json
    true
    ```
  
  - `is_jingle` (optional)
    Type: boolean
    
    If yes, do not send jingle metadata to AutoDJ or trigger web hooks.
    
    Example:
    
    ```json
    false
    ```
  
  - `play_per_songs` (optional)
    Type: integer
    
    Example:
    
    ```json
    5
    ```
  
  - `play_per_minutes` (optional)
    Type: integer
    
    Example:
    
    ```json
    120
    ```
  
  - `play_per_hour_minute` (optional)
    Type: integer
    
    Example:
    
    ```json
    15
    ```
  
  - `weight` (optional)
    Type: integer
    
    The relative weight of the playlist. Larger numbers play more often than playlists with lower number weights.
    
    Example:
    
    ```json
    3
    ```
  
  - `include_in_requests` (optional)
    Type: boolean
    
    Example:
    
    ```json
    true
    ```
  
  - `include_in_on_demand` (optional)
    Type: boolean
    
    Whether this playlist's media is included in 'on demand' download/streaming if enabled.
    
    Example:
    
    ```json
    true
    ```
  
  - `backend_options` (optional)
    Type: array
    
    Example:
    
    ```json
    "interrupt,loop_once,single_track,merge"
    ```
    
    Items:
      Type: string
  
  - `avoid_duplicates` (optional)
    Type: boolean
    
    Example:
    
    ```json
    true
    ```
  
  - `preserve_queue_on_restart` (optional)
    Type: boolean
    
    Don't reset this playlist's queue when the station is restarted or its configuration is rewritten.
    
    Example:
    
    ```json
    false
    ```
  
  - `schedule_items` (optional)
    Type: array
    
    Items:
      Type: unknown
  
  - `podcasts` (optional)
    Type: array
    
    Items:
      Type: unknown
  
  - `playlists` (optional)
    Type: array
    
    Items:
      Type: unknown

Responses:

- 200: Success

Content type: application/json

Type: object

Schema: [Api_Status](https://sourcey-azuracast.pages.dev/docs/api/models/api-status/index.md)

- `success` (required)
  Type: boolean
  
  Example:
  
  ```json
  true
  ```

- `message` (required)
  Type: string
  
  Example:
  
  ```json
  "Changes saved successfully."
  ```

- `formatted_message` (required)
  Type: string
  
  Example:
  
  ```json
  "<b>Changes saved successfully.</b>"
  ```

- 403: Access denied.

Content type: application/json

Type: object

Schema: [Api_Error](https://sourcey-azuracast.pages.dev/docs/api/models/api-error/index.md)

- `code` (required)
  Type: integer
  
  The numeric code of the error.
  
  Example:
  
  ```json
  500
  ```

- `type` (required)
  Type: string
  
  The programmatic class of error.
  
  Example:
  
  ```json
  "NotLoggedInException"
  ```

- `message` (required)
  Type: string
  
  The text description of the error.
  
  Example:
  
  ```json
  "Error description."
  ```

- `formatted_message` (required)
  Type: string; nullable
  
  The HTML-formatted text description of the error.
  
  Example:
  
  ```json
  "<b>Error description.</b><br>Detailed error text."
  ```

- `extra_data` (required)
  Type: array
  
  Stack traces and other supplemental data.
  
  Items:
    Type: any

- `success` (required)
  Type: boolean
  
  Used for API calls that expect an \Entity\Api\Status type response.
  
  Example:
  
  ```json
  false
  ```

- 404: Record not found.

Content type: application/json

Type: object

Schema: [Api_Error](https://sourcey-azuracast.pages.dev/docs/api/models/api-error/index.md)

- `code` (required)
  Type: integer
  
  The numeric code of the error.
  
  Example:
  
  ```json
  500
  ```

- `type` (required)
  Type: string
  
  The programmatic class of error.
  
  Example:
  
  ```json
  "NotLoggedInException"
  ```

- `message` (required)
  Type: string
  
  The text description of the error.
  
  Example:
  
  ```json
  "Error description."
  ```

- `formatted_message` (required)
  Type: string; nullable
  
  The HTML-formatted text description of the error.
  
  Example:
  
  ```json
  "<b>Error description.</b><br>Detailed error text."
  ```

- `extra_data` (required)
  Type: array
  
  Stack traces and other supplemental data.
  
  Items:
    Type: any

- `success` (required)
  Type: boolean
  
  Used for API calls that expect an \Entity\Api\Status type response.
  
  Example:
  
  ```json
  false
  ```

- 500: A generic exception has occurred.

Content type: application/json

Type: object

Schema: [Api_Error](https://sourcey-azuracast.pages.dev/docs/api/models/api-error/index.md)

- `code` (required)
  Type: integer
  
  The numeric code of the error.
  
  Example:
  
  ```json
  500
  ```

- `type` (required)
  Type: string
  
  The programmatic class of error.
  
  Example:
  
  ```json
  "NotLoggedInException"
  ```

- `message` (required)
  Type: string
  
  The text description of the error.
  
  Example:
  
  ```json
  "Error description."
  ```

- `formatted_message` (required)
  Type: string; nullable
  
  The HTML-formatted text description of the error.
  
  Example:
  
  ```json
  "<b>Error description.</b><br>Detailed error text."
  ```

- `extra_data` (required)
  Type: array
  
  Stack traces and other supplemental data.
  
  Items:
    Type: any

- `success` (required)
  Type: boolean
  
  Used for API calls that expect an \Entity\Api\Status type response.
  
  Example:
  
  ```json
  false
  ```

## Examples

### cURL

```bash
curl -X PUT 'https://demo.azuracast.com/api/station/0/playlist/0' \
  -H 'X-API-Key: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "name": "Test Playlist",
  "description": "A playlist containing my favorite songs",
  "type": "default",
  "source": "songs",
  "order": "random",
  "remote_url": "https://remote-url.example.com/stream.mp3",
  "remote_type": "stream",
  "remote_buffer": 0,
  "is_enabled": true,
  "is_jingle": false,
  "play_per_songs": 5,
  "play_per_minutes": 120,
  "play_per_hour_minute": 15,
  "weight": 3,
  "include_in_requests": true,
  "include_in_on_demand": true,
  "backend_options": "interrupt,loop_once,single_track,merge",
  "avoid_duplicates": true,
  "preserve_queue_on_restart": false,
  "schedule_items": [],
  "podcasts": [],
  "playlists": []
}'
```

### JavaScript

```javascript
const body = `{
  "name": "Test Playlist",
  "description": "A playlist containing my favorite songs",
  "type": "default",
  "source": "songs",
  "order": "random",
  "remote_url": "https://remote-url.example.com/stream.mp3",
  "remote_type": "stream",
  "remote_buffer": 0,
  "is_enabled": true,
  "is_jingle": false,
  "play_per_songs": 5,
  "play_per_minutes": 120,
  "play_per_hour_minute": 15,
  "weight": 3,
  "include_in_requests": true,
  "include_in_on_demand": true,
  "backend_options": "interrupt,loop_once,single_track,merge",
  "avoid_duplicates": true,
  "preserve_queue_on_restart": false,
  "schedule_items": [],
  "podcasts": [],
  "playlists": []
}`;

const response = await fetch('https://demo.azuracast.com/api/station/0/playlist/0', {
  method: 'PUT',
  headers: {
    'X-API-Key': 'YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

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

### Python

```python
import requests

body = '''{
  "name": "Test Playlist",
  "description": "A playlist containing my favorite songs",
  "type": "default",
  "source": "songs",
  "order": "random",
  "remote_url": "https://remote-url.example.com/stream.mp3",
  "remote_type": "stream",
  "remote_buffer": 0,
  "is_enabled": true,
  "is_jingle": false,
  "play_per_songs": 5,
  "play_per_minutes": 120,
  "play_per_hour_minute": 15,
  "weight": 3,
  "include_in_requests": true,
  "include_in_on_demand": true,
  "backend_options": "interrupt,loop_once,single_track,merge",
  "avoid_duplicates": true,
  "preserve_queue_on_restart": false,
  "schedule_items": [],
  "podcasts": [],
  "playlists": []
}'''

response = requests.put(
    'https://demo.azuracast.com/api/station/0/playlist/0',
    data=body.encode('utf-8'),
    headers={
        'X-API-Key': 'YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
