# Update details of a single file.

`PUT /station/{station_id}/file/{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

- `media_id` (path, integer, int64, required) - Media ID
  Type: integer, int64

Request body: application/json

Type: object

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

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

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

  Type: object
  
  - `id` (optional)
    Type: integer
    
    The media's identifier.
    
    Example:
    
    ```json
    1
    ```
  
  - `unique_id` (optional)
    Type: string
    
    A unique identifier for this specific media item in the station's library. Each entry in the media table has a unique ID, even if it refers to a song that exists elsewhere.
    
    Example:
    
    ```json
    "69b536afc7ebbf16457b8645"
    ```
  
  - `song_id` (optional)
    Type: string
    
    The media file's 32-character unique song identifier hash. This hash is based on track metadata, so the same song uploaded multiple times will have the same `song_id`.
    
    Example:
    
    ```json
    "9f33bbc912c19603e51be8e0987d076b"
    ```
  
  - `art` (optional)
    Type: string
    
    URL to the album art.
    
    Example:
    
    ```json
    "https://picsum.photos/1200/1200"
    ```
  
  - `path` (optional)
    Type: string
    
    The relative path of the media file.
    
    Example:
    
    ```json
    "test.mp3"
    ```
  
  - `mtime` (optional)
    Type: integer
    
    The UNIX timestamp when the database was last modified.
    
    Example:
    
    ```json
    1609480800
    ```
  
  - `uploaded_at` (optional)
    Type: integer
    
    The UNIX timestamp when the item was first imported into the database.
    
    Example:
    
    ```json
    1609480800
    ```
  
  - `art_updated_at` (optional)
    Type: integer
    
    The latest time (UNIX timestamp) when album art was updated.
    
    Example:
    
    ```json
    1609480800
    ```
  
  - `length` (optional)
    Type: number, float
    
    The song duration in seconds.
    
    Example:
    
    ```json
    240
    ```
  
  - `length_text` (optional)
    Type: string
    
    The formatted song duration (in mm:ss format)
    
    Example:
    
    ```json
    "4:00"
    ```
  
  - `custom_fields` (optional)
    Reference: [HashMap](https://sourcey-azuracast.pages.dev/docs/api/models/hashmap/index.md); Type: object
    
    A hash-map array represented as an object.
  
  - `extra_metadata` (optional)
    Reference: [HashMap](https://sourcey-azuracast.pages.dev/docs/api/models/hashmap/index.md); Type: object
    
    A hash-map array represented as an object.
  
  - `playlists` (optional)
    Type: array
    
    Items:
      Type: unknown
      
      oneOf:
        Reference: [Api_StationMediaPlaylist](https://sourcey-azuracast.pages.dev/docs/api/models/api-stationmediaplaylist/index.md); Type: object
      
        Type: integer
        
        writeOnly: true

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/file/%7Bid%7D' \
  -H 'X-API-Key: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "text": "Chet Porter - Aluko River",
  "artist": "Chet Porter",
  "title": "Aluko River",
  "album": "Moving Castle",
  "genre": "Rock",
  "isrc": "US28E1600021",
  "lyrics": "",
  "id": 1,
  "unique_id": "69b536afc7ebbf16457b8645",
  "song_id": "9f33bbc912c19603e51be8e0987d076b",
  "art": "https://picsum.photos/1200/1200",
  "path": "test.mp3",
  "mtime": 1609480800,
  "uploaded_at": 1609480800,
  "art_updated_at": 1609480800,
  "length": 240,
  "length_text": "4:00",
  "custom_fields": {},
  "extra_metadata": {},
  "playlists": [
    {
      "id": 1
    }
  ]
}'
```

### JavaScript

```javascript
const body = `{
  "text": "Chet Porter - Aluko River",
  "artist": "Chet Porter",
  "title": "Aluko River",
  "album": "Moving Castle",
  "genre": "Rock",
  "isrc": "US28E1600021",
  "lyrics": "",
  "id": 1,
  "unique_id": "69b536afc7ebbf16457b8645",
  "song_id": "9f33bbc912c19603e51be8e0987d076b",
  "art": "https://picsum.photos/1200/1200",
  "path": "test.mp3",
  "mtime": 1609480800,
  "uploaded_at": 1609480800,
  "art_updated_at": 1609480800,
  "length": 240,
  "length_text": "4:00",
  "custom_fields": {},
  "extra_metadata": {},
  "playlists": [
    {
      "id": 1
    }
  ]
}`;

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

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

### Python

```python
import requests

body = '''{
  "text": "Chet Porter - Aluko River",
  "artist": "Chet Porter",
  "title": "Aluko River",
  "album": "Moving Castle",
  "genre": "Rock",
  "isrc": "US28E1600021",
  "lyrics": "",
  "id": 1,
  "unique_id": "69b536afc7ebbf16457b8645",
  "song_id": "9f33bbc912c19603e51be8e0987d076b",
  "art": "https://picsum.photos/1200/1200",
  "path": "test.mp3",
  "mtime": 1609480800,
  "uploaded_at": 1609480800,
  "art_updated_at": 1609480800,
  "length": 240,
  "length_text": "4:00",
  "custom_fields": {},
  "extra_metadata": {},
  "playlists": [
    {
      "id": 1
    }
  ]
}'''

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