# Set up Apple Music
URL: https://musicapi.com/docs/connect-users/configure-apple-music.md

> What you need from the Apple Developer portal (Team ID, Key ID, private key, Services ID), the Sign in with Apple return URL, and the Apple Music limits.

Product: MusicAPI Core and MusicAPI Managed Transfers. Section: Connect your users.

> **Managed integration:** A `transferring` sign-up gets copies of the integrations that MusicAPI runs. When your **Integrations** page already lists Apple Music, users can sign in with no setup on your side. Set up your own Apple keys when your account has no Apple Music integration, or when the developer token must be in your company's name.

## What you need from Apple

A paid Apple Developer Program membership, then:

| Apple value                    | Where you find it                                                                                                                                                                                         | MusicAPI field      |
| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
| Team ID                        | [developer.apple.com/account](https://developer.apple.com/account), membership details                                                                                                                    | Team ID             |
| Key ID and private key (`.p8`) | Certificates, Identifiers & Profiles → Keys. [Create a media identifier and private key](https://developer.apple.com/help/account/configure-app-capabilities/create-a-media-identifier-and-private-key/). | Key ID, Private Key |
| Services ID                    | Identifiers → Services IDs. [Register a Services ID](https://developer.apple.com/help/account/manage-identifiers/register-a-services-id).                                                                 | Client ID           |

The key must have both **Media Services (MusicKit)** and **Sign in with Apple** turned on. A key without both fails with `{"message": "Invalid token specified"}`.

## Return URL and domains

On the Services ID, configure **Sign in with Apple**:

- **Domains and subdomains**: `api.musicapi.com` and `app.musicapi.com`
- **Return URL**:

```url
https://api.musicapi.com/callback/apple_sign_in
```

## How the Apple sign-in works

The user signs in with Apple, then MusicKit asks for access to their library. MusicAPI signs the developer token with your private key, stores the MusicKit user token, and handles the storefront and the library-versus-catalog ids for you. Apple Music has no OAuth scopes to pick.

## Add it to MusicAPI

1. Open **Integrations** in the dashboard and pick Apple Music.
2. Paste the Team ID, the Key ID, the Client ID (Services ID) and the private key, and save.
3. Turn **Is Enabled** on.
4. Press **Test Apple Music** and sign in once with your own Apple account.

## Quirks

Apple's API allows less than most services. With Apple Music you **cannot**:

- rename or re-describe a playlist, or delete one;
- remove or reorder tracks in a playlist, or remove liked tracks;
- remove a saved album, or follow and unfollow artists.

Creating playlists, adding tracks, liking tracks and saving albums work. The email comes from the Sign in with Apple id token of each sign-in; an account that signed in before has it after its next sign-in. At most 25 items per page (`limitParam`). Tracks carry an ISRC, and the user search takes one.

## Direct sign-in link

```url
https://app.musicapi.com/{slug}/appleMusic/auth?returnUrl={returnUrl}
```
