# Sammlungen | AudioDN Docs

> API-Endpunkte zum Erstellen, Aktualisieren, Auflisten und Löschen von Audio-Sammlungen in AudioDN. Organisieren Sie Tracks in Alben, Playlists oder Ordnern.

Source: https://audiodeliverynetwork.com/de/docs/api/collections/

---

# Sammlungen

Sammlungen sind Container zur Organisation Ihrer Audio-Tracks. Sie können Sammlungsinformationen erstellen, aktualisieren, abrufen und löschen.

Antworten enthalten zwei schreibgeschützte Begleitfelder zu `player_color`: `player_color_light` (angepasst für Lesbarkeit auf hellem Hintergrund) und `player_color_dark` (angepasst für dunklen Hintergrund). Sie werden aus `player_color` abgeleitet, indem die Helligkeit verschoben wird, bis jeder einen Mindestkontrast erreicht, und können nicht direkt gesetzt werden.

GET `/v1/collection`

Gibt eine Liste von Sammlungen für eine Organisation zurück

#### Parameter

| Name | Typ | Erforderlich | Beschreibung |
| --- | --- | --- | --- |
| `limit` | number | Optional | Maximale Anzahl zurückzugebender Sammlungen |
| `offset` | number | Optional | Anzahl zu überspringender Sammlungen |

#### Beispielanfrage

    

```
curl -X GET "https://api.audiodelivery.net/v1/collection" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

```
const response = await fetch('https://api.audiodelivery.net/v1/collection', {
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
  }
});

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

```
import Foundation

func performRequest() async throws {
    var request = URLRequest(url: URL(string: "https://api.audiodelivery.net/v1/collection")!)
    request.httpMethod = "GET"
    request.setValue("Bearer YOUR_API_KEY", forHTTPHeaderField: "Authorization")
    let (data, _) = try await URLSession.shared.data(for: request)
    let json = try JSONSerialization.jsonObject(with: data) as! [String: Any]
    // use json
}
```

```
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.*

val client = OkHttpClient()

suspend fun performRequest(): String = withContext(Dispatchers.IO) {
    val request = Request.Builder()
        .url("https://api.audiodelivery.net/v1/collection")
        .addHeader("Authorization", "Bearer YOUR_API_KEY")
        .build()
    val response = client.newCall(request).execute()
    response.body?.string() ?: error("Empty response body")
}
```

```
import 'dart:convert';
import 'package:http/http.dart' as http;

Future<Map<String, dynamic>> performRequest() async {
  final response = await http.get(
    Uri.parse("https://api.audiodelivery.net/v1/collection"),
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
    },
  );
  if (response.statusCode < 200 || response.statusCode >= 300) {
    throw Exception('Request failed: ${response.statusCode}');
  }
  return jsonDecode(response.body) as Map<String, dynamic>;
}
```

#### Antwort

```
{
"ok": true,
"api_request_id": "uuid",
"count": 0,
"collections": [
  {
    "id": "uuid",
    "organization_id": "uuid",
    "creator_id": "uuid | null",
    "title": "string",
    "organization_index": "string | null",
    "metadata": {},
    "theme": [],
    "player_color": "string | null",
    "player_color_light": "string | null",
    "player_color_dark": "string | null",
    "player_subtitle": "string | null",
    "is_cover_overridable": true,
    "is_theme_overridable": true
  }
]
}
```

GET `/v1/collection/:collection_id`

Gibt Details zu einer bestimmten Sammlung zurück

#### Parameter

| Name | Typ | Erforderlich | Beschreibung |
| --- | --- | --- | --- |
| `collection_id` | uuid | Erforderlich | Die ID der abzurufenden Sammlung (Pfadparameter) |

#### Antwort

```
{
"ok": true,
"api_request_id": "uuid",
"collection_id": "uuid",
"collection": {
  "id": "uuid",
  "organization_id": "uuid",
  "creator_id": "uuid | null",
  "title": "string",
  "organization_index": "string | null",
  "metadata": {},
  "theme": [],
  "player_color": "string | null",
  "player_color_light": "string | null",
  "player_color_dark": "string | null",
  "player_subtitle": "string | null",
  "is_cover_overridable": true,
  "is_theme_overridable": true
}
}
```

POST `/v1/collection`

Erstellt eine neue Sammlung

#### Parameter

| Name | Typ | Erforderlich | Beschreibung |
| --- | --- | --- | --- |
| `title` | string | Erforderlich | Titel der Sammlung |
| `creator_id` | uuid | Optional | ID des Creators, dem die Sammlung gehört |
| `organization_index` | string | Optional | Organisations-Kennung |
| `metadata` | object | Optional | Organisations-Metadaten für die Sammlung |
| `theme` | array of objects | Optional | Aus Coverbildern extrahierte Farben |
| `is_cover_overridable` | boolean | Optional | Ob das Sammlungs-Cover auf Track-Ebene überschrieben werden kann |
| `is_theme_overridable` | boolean | Optional | Ob Sammlungs-Bildfarben auf Track-Ebene überschrieben werden können |
| `player_color` | string | Optional | Player-Farbe (Hex-Farbe) |
| `player_subtitle` | string | Optional | Player-Untertitel |

#### Beispielanfrage

    

```
curl -X POST "https://api.audiodelivery.net/v1/collection" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "title": "My Collection",
  "player_subtitle": "Artist Name"
}'
```

```
const payload = {
  "title": "My Collection",
  "player_subtitle": "Artist Name"
};

const response = await fetch('https://api.audiodelivery.net/v1/collection', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(payload)
});

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

```
import Foundation

func performRequest() async throws {
    var request = URLRequest(url: URL(string: "https://api.audiodelivery.net/v1/collection")!)
    request.httpMethod = "POST"
    request.setValue("Bearer YOUR_API_KEY", forHTTPHeaderField: "Authorization")
    request.setValue("application/json", forHTTPHeaderField: "Content-Type")
    let bodyJSON = """
{
  "title": "My Collection",
  "player_subtitle": "Artist Name"
}
"""
    request.httpBody = bodyJSON.data(using: .utf8)
    let (data, _) = try await URLSession.shared.data(for: request)
    let json = try JSONSerialization.jsonObject(with: data) as! [String: Any]
    // use json
}
```

```
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.toRequestBody

val client = OkHttpClient()

suspend fun performRequest(): String = withContext(Dispatchers.IO) {
    val body = """{
  "title": "My Collection",
  "player_subtitle": "Artist Name"
}""".toRequestBody("application/json".toMediaType())
    val request = Request.Builder()
        .url("https://api.audiodelivery.net/v1/collection")
        .post(body)
        .addHeader("Authorization", "Bearer YOUR_API_KEY")
        .addHeader("Content-Type", "application/json")
        .build()
    val response = client.newCall(request).execute()
    response.body?.string() ?: error("Empty response body")
}
```

```
import 'dart:convert';
import 'package:http/http.dart' as http;

Future<Map<String, dynamic>> performRequest() async {
  final response = await http.post(
    Uri.parse("https://api.audiodelivery.net/v1/collection"),
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: jsonEncode({
  "title": "My Collection",
  "player_subtitle": "Artist Name"
}),
  );
  if (response.statusCode < 200 || response.statusCode >= 300) {
    throw Exception('Request failed: ${response.statusCode}');
  }
  return jsonDecode(response.body) as Map<String, dynamic>;
}
```

#### Antwort

```
{
"ok": true,
"api_request_id": "uuid",
"collection_id": "uuid",
"collection": {
  "id": "uuid",
  "organization_id": "uuid",
  "creator_id": "uuid | null",
  "title": "string",
  "organization_index": "string | null",
  "metadata": {},
  "theme": [],
  "player_color": "string | null",
  "player_color_light": "string | null",
  "player_color_dark": "string | null",
  "player_subtitle": "string | null",
  "is_cover_overridable": true,
  "is_theme_overridable": true
},
"collection_cover_upload": {
  "method": "POST",
  "upload_url": "string",
  "ttl": 3600,
  "expires_at": "string"
}
}
```

PUT `/v1/collection/:collection_id`

Aktualisiert eine bestehende Sammlung

#### Parameter

| Name | Typ | Erforderlich | Beschreibung |
| --- | --- | --- | --- |
| `collection_id` | uuid | Erforderlich | Die ID der zu aktualisierenden Sammlung (Pfadparameter) |
| `creator_id` | uuid | Optional | Creator-ID |
| `organization_index` | string | Optional | Organisations-Kennung |
| `title` | string | Optional | Titel der Sammlung |
| `metadata` | object | Optional | Organisations-Metadaten |
| `theme` | array of objects | Optional | Aus Coverbildern extrahierte Farben |
| `is_cover_overridable` | boolean | Optional | Ob das Sammlungs-Cover auf Track-Ebene überschrieben werden kann |
| `is_theme_overridable` | boolean | Optional | Ob Sammlungs-Bildfarben auf Track-Ebene überschrieben werden können |
| `player_color` | string | Optional | Player-Farbe (Hex-Farbe) |
| `player_subtitle` | string | Optional | Player-Untertitel |

#### Antwort

```
{
"ok": true,
"api_request_id": "uuid",
"collection_id": "uuid",
"collection": {
  "id": "uuid",
  "organization_id": "uuid",
  "creator_id": "uuid | null",
  "title": "string",
  "organization_index": "string | null",
  "metadata": {},
  "theme": [],
  "player_color": "string | null",
  "player_color_light": "string | null",
  "player_color_dark": "string | null",
  "player_subtitle": "string | null",
  "is_cover_overridable": true,
  "is_theme_overridable": true
}
}
```

DELETE `/v1/collection/:collection_id`

Löscht eine Sammlung soft und kaskadiert zu ihren Tracks

#### Parameter

| Name | Typ | Erforderlich | Beschreibung |
| --- | --- | --- | --- |
| `collection_id` | uuid | Erforderlich | Die ID der zu löschenden Sammlung (Pfadparameter) |

Das Löschen einer Sammlung **kaskadiert**: Jeder enthaltene Track wird soft-gelöscht, einschließlich der Varianten und Dateien jedes Tracks. Entfernte Dateien werden zur Löschung aus dem Objektspeicher in die Warteschlange gestellt.

#### Beispielanfrage

    

```
curl -X DELETE "https://api.audiodelivery.net/v1/collection/COLLECTION_ID" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

```
const response = await fetch('https://api.audiodelivery.net/v1/collection/COLLECTION_ID', {
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
  }
});

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

```
import Foundation

func performRequest() async throws {
    var request = URLRequest(url: URL(string: "https://api.audiodelivery.net/v1/collection/COLLECTION_ID")!)
    request.httpMethod = "DELETE"
    request.setValue("Bearer YOUR_API_KEY", forHTTPHeaderField: "Authorization")
    let (data, _) = try await URLSession.shared.data(for: request)
    let json = try JSONSerialization.jsonObject(with: data) as! [String: Any]
    // use json
}
```

```
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.*

val client = OkHttpClient()

suspend fun performRequest(): String = withContext(Dispatchers.IO) {
    val request = Request.Builder()
        .url("https://api.audiodelivery.net/v1/collection/COLLECTION_ID")
        .delete()
        .addHeader("Authorization", "Bearer YOUR_API_KEY")
        .build()
    val response = client.newCall(request).execute()
    response.body?.string() ?: error("Empty response body")
}
```

```
import 'dart:convert';
import 'package:http/http.dart' as http;

Future<Map<String, dynamic>> performRequest() async {
  final response = await http.delete(
    Uri.parse("https://api.audiodelivery.net/v1/collection/COLLECTION_ID"),
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
    },
  );
  if (response.statusCode < 200 || response.statusCode >= 300) {
    throw Exception('Request failed: ${response.statusCode}');
  }
  return jsonDecode(response.body) as Map<String, dynamic>;
}
```

#### Antwort

```
{
"ok": true,
"api_request_id": "uuid",
"collection_id": "uuid",
"deleted_collection": {
  "id": "uuid",
  "organization_id": "uuid",
  "creator_id": "uuid | null",
  "title": "string",
  "organization_index": "string | null",
  "metadata": {},
  "theme": [],
  "player_color": "string | null",
  "player_color_light": "string | null",
  "player_color_dark": "string | null",
  "player_subtitle": "string | null"
}
}
```
