create-apple-report-request

Exact captured content · path skills/create-apple-report-request/SKILL.md · sha256 2af71906e2274ee4… · revision 8c0fb5d925d1b23fcfbcc34da0f610c8754825cd

Download the exact captured file

---
name: create-apple-report-request
description: Do or guide the one-time Apple step that iOS reports need. A Sales and Reports key is created first and used to check whether the app already has an ONGOING Analytics report request. Only if none exists is a temporary Admin key created, kept private on the customer's machine, used to create exactly one request, and then revoked. The reader key is handed to InstallTally. When the customer chose agent-assisted setup, the agent does the console work in a browser they watch; otherwise it guides them step by step. Use when InstallTally setup shows needs_admin_bootstrap, when Apple refuses analytics report requests for an existing key, or when a customer asks how to start Apple reports.
---

# Create the Apple report request

Apple generates analytics reports only after an ONGOING report request exists for the app, and only a key with the **Admin** role can create one. The permanent Sales and Reports reader that InstallTally stores can read requests and reports but cannot create them. This skill gets the reader in place and, only when needed, uses a temporary Admin key once. It never uploads the Admin key.

Talk to the customer in their language. Keep commands, key names and Apple's menu labels as written here.

## Choose how to run it

Reuse what the customer already chose in this conversation; ask only if there is none.

- **Existing reader**: the customer already has a Sales and Reports key file. Do not create a new one. Write `reader-check.json` for the key they name and start at the reader check: step 3A.6 or the check in step 3B.2. If it returns `needs_admin_bootstrap` in agent-assisted mode, first do steps 3A.1–3A.4; the step-3 confirmation then lists only the Admin key, the request and its revocation.
- **Agent-assisted** (section 3A): only when the customer explicitly asks the agent to do the console work, the agent can control a browser the customer can watch, and downloads can be kept private (step 3A.4). This choice covers this customer only; never reuse another customer's consent.
- **Guided** (section 3B, every other case): the customer clicks in App Store Connect; the agent runs the local commands.

Do not assume any particular browser tool. Never switch to a browser as a fallback when the customer chose another method. The setup-app-store-reports rule against opening a browser applies to every method except an explicitly chosen agent-assisted run.

## Before you start

Tell the customer what they need, so nobody stops halfway:

- **An App Store Connect user with the Admin role, or the Account Holder.** Only they can create team keys. Keys with roles such as App Manager or Developer cannot create the report request.
- **Agreements in effect.** If Apple refuses even a simple read of the app with "A required agreement is missing or has expired", the Account Holder must accept the pending agreements under **Business** first.
- **The InstallTally account that owns the workspace.** People often have several Google accounts, and InstallTally stores no e-mail address, so ask which account created the workspace.
- **About ten minutes now.** Apple usually prepares the first reports one to two days later.

Check your own prerequisites before any key is created: you can run commands on the customer's macOS or Linux machine, and either the official companion tool `bootstrap_apple_reports` is loaded or `node --version` shows 22.17 or later and you know where the InstallTally plugin is installed. Otherwise stop and say what is missing. Windows is not covered.

## 1. Check what already exists

1. Identify the app: the InstallTally product and its numeric App Store ID. Verify the ID against the app repository or the customer, never by name alone. On a team with several apps, confirm which one.
2. If the owner MCP is connected, read `get_provider_setup` and the App Store sources. When a source is already bound, the server reports an active request, or it shows `waiting_for_report_definition`, stop: nothing here is needed. If `get_provider_setup` shows `credential_saved=true`, InstallTally already holds a reader: do not create, download or hand over another Sales and Reports key. A server `needs_admin_bootstrap` already means no active request was found, so go straight to the Admin step (3A.7 after steps 3A.1–3A.4, or 3B.1, the section 2 `mkdir` command, then 3B.3) and verify with `bootstrap.json` before revoking. Once the request exists, read the current revision and resume the server task with `set_provider_setup_background` or `advance_provider_setup`, as [private transfer](../setup/references/private-transfer.md) describes; do not upload again.
3. A key that can read the app is not necessarily Admin. The helper reports every Apple refusal (HTTP 403) as `permission`; it cannot tell a missing role from a pending agreement.

## 2. Private folder and manifests

Keys live in an owner-only folder, and the helper reads a small manifest per key:

```
mkdir -p ~/.config/installtally/apple && chmod 700 ~/.config/installtally/apple && echo $HOME
```

Create each manifest with owner-only permissions from the start. JSON does not expand `~`, so use the printed home folder in place of `<HOME>`:

```
(umask 077; printf '%s\n' '{"issuer_id":"<Issuer ID>","key_id":"<KEY ID>","private_key_path":"<HOME>/.config/installtally/apple/AuthKey_<KEY ID>.p8"}' > ~/.config/installtally/apple/<NAME>.json) && ls -l ~/.config/installtally/apple
```

Use `reader-check.json` for the Sales and Reports key and `bootstrap.json` for the Admin key. The helper refuses a manifest or key file with any group or other permission bit, a file that is itself a symlink, a relative path, or a manifest with keys other than these three.

- Never ask for, open, print or paste a key's contents, and never put a key file in a repository, chat, MCP argument or upload form.
- Use only key files that you downloaded in section 3A or that the customer names for this purpose. Do not search the disk for other `.p8` files, and do not try a key you found unless the customer names it and confirms its role.
- Run `chmod 600` on files you downloaded yourself. If the customer points to a file of theirs with wider permissions, ask before tightening them, and report that you did.

## 3A. Agent-assisted: the agent does the console work

Work in a new browser tab the customer can see. Never read cookies, tokens or page storage, and stay on App Store Connect.

1. **Sign-in.** Open https://appstoreconnect.apple.com/access/integrations/api. The agent's browser usually has its own session, so being signed in elsewhere does not count. The customer signs in inside the visible tab, with a password or a passkey, and completes two-factor authentication; never type passwords or codes. Do not copy or import cookies or sessions from another browser: that moves every logged-in session of the profile, not just Apple's. Check from the page that the sign-in worked.
2. **Verify the account from the page.** Read the team name, confirm the app with the expected App Store ID exists under **Apps**, and read the **Issuer ID** above the key list. A missing app usually means the wrong team: stop and ask. If the page offers **Request Access** or reports a missing agreement, only the Account Holder can fix it; stop. Read the active key list (names, IDs, roles). Apple never offers a second download of an existing key, so reuse one only if the customer still has its file.
3. **One confirmation for every console change.** List exactly: the team; key `InstallTally reports` with role Sales and Reports; key `InstallTally bootstrap` with role Admin **only if no active request exists**; one ONGOING report request for the app name and App Store ID, if needed; revoking `InstallTally bootstrap` right after; handing the reader to InstallTally through the companion's private transfer. Say that team keys cover every app on the team. Continue only after a clear yes. Anything outside this list needs a new confirmation.
4. **Private downloads.** If the browser tool can set a download folder, point it at the private folder. Otherwise find out where the browser saves files and check that folder is owner-only (for example `drwx------`). If neither works, switch to section 3B for the downloads. A browser can accept a download-folder setting and still save elsewhere, so after every download check where the file landed, by its exact name, move it into the private folder if needed, and run `chmod 600`.
5. **Create the reader.** Click **+** next to the active key count, enter `InstallTally reports`, open **Access**, choose **Sales and Reports**, and check the form before **Generate**. Apple's role list also offers Admin, App Manager, Developer, Finance, Customer Support and Marketing; the new key shows its access as "Access to Reports, Sales". Click the key's **Download** link once and confirm Apple's one-time download dialog. Never open the file. After a timeout or an unclear page, read the key list again before any retry; never generate a second key for the same purpose.
6. **Check for an existing request** with `reader-check.json` and the read-only call (section 4). `request_ready` means a request exists: skip to step 9. `needs_admin_bootstrap` means none exists: continue.
7. **Create the Admin key and the request.** Create `InstallTally bootstrap` the same way with role **Admin**, download it, write `bootstrap.json`, and run section 4: read-only, then create. The step-3 confirmation is the approval for this one request.
8. **Revoke the Admin key.** First rerun the reader check (or, when step 1.2 applies, the read-only call with `bootstrap.json`): it should return `request_ready` with the same request ID. If it does not, do not run the create call again: report the result, then still revoke the Admin key. Then click **Edit**, tick only the `InstallTally bootstrap` row, check that no other row is ticked, click **Revoke Key** and confirm. Apple's dialog does not name the key, so the row check is the safeguard. The list then shows the key under **Revoked**, and a read-only call with `bootstrap.json` returns `authentication`. Delete the Admin key file and `bootstrap.json`.
9. **Hand over the reader** through the companion's private transfer in [setup-app-store-reports](../setup-app-store-reports/SKILL.md): package `InstallTally reports` with the companion's `prepare_apple_reader` ([prepare-store-access](../prepare-store-access/SKILL.md)) and transfer that file. `reader-check.json` and `bootstrap.json` are helper manifests; never pass them to `prepare_private_transfer`. Do not open the InstallTally panel. If the companion is unavailable, stop, keep the reader in the private folder and report that blocker. Apple currently names the detailed downloads report **App Downloads Detailed** (category COMMERCE); older documentation calls it App Store Downloads Detailed. If Apple lists no reports yet, the reader stays saved; setup resumes automatically only if the background task is enabled, otherwise report that a later advance is needed. Apple usually prepares reports within a day or two.
10. Delete `reader-check.json`, return the browser downloads to their previous setting, and leave the customer's other tabs alone.

## 3B. Guided: the customer does the console work

The customer clicks in App Store Connect with a user that has the Admin role or is the Account Holder. You do not sign in, open the console for them or handle their password.

1. The customer opens **Users and Access → Integrations → App Store Connect API → Team Keys**: https://appstoreconnect.apple.com/access/integrations/api. If the page offers **Request Access**, only the Account Holder can enable the API; a missing or expired agreement must be accepted under **Business** first.
2. **Reader first.** Run the section 2 `mkdir` command before the customer downloads anything. The customer clicks **+**, creates `InstallTally reports` with role **Sales and Reports**, downloads the file once (Apple allows one download), and copies the **Issuer ID** shown above the key list. Give them this command with their key ID in place of `XXXXXXXXXX`:
   ```
   mv ~/Downloads/AuthKey_XXXXXXXXXX.p8 ~/.config/installtally/apple/ && chmod 600 ~/.config/installtally/apple/AuthKey_XXXXXXXXXX.p8
   ```
   They reply with the key ID and the Issuer ID. Write `reader-check.json` and run the read-only call (section 4). `request_ready`: no Admin key is needed; go to section 5. `needs_admin_bootstrap`: continue.
3. **Admin only if needed.** Say that team keys cover every app on the team. The customer creates `InstallTally bootstrap` with role **Admin**, downloads it and moves it the same way. Write `bootstrap.json` and run section 4: read-only, then create with approval.
4. Rerun the reader check (or, when step 1.2 applies, the read-only call with `bootstrap.json`): it must return `request_ready` with the same request ID. Then the customer revokes the Admin key: **Edit**, tick only `InstallTally bootstrap`, **Revoke Key**, confirm. Apple's dialog does not name the key, so the tick is what matters. Check that a read-only call with `bootstrap.json` now returns `authentication`, then delete the Admin key file, `bootstrap.json` and `reader-check.json`.

## 4. The helper: read first, then create with approval

Prefer the companion tool `bootstrap_apple_reports` with `app_id`, the absolute manifest path as `credential_manifest`, and `approve_create: false`. Without the companion, run the bundled [Apple helper](../setup-app-store-reports/scripts/apple-bootstrap.mjs), replacing `<plugin>` with the plugin's install path:

```
node <plugin>/skills/setup-app-store-reports/scripts/apple-bootstrap.mjs --credentials ~/.config/installtally/apple/<NAME>.json --app-id <App Store ID>
```

The helper signs short-lived tokens locally and talks only to Apple's API. On success it prints one JSON line on stdout; on failure it prints `{"error_code":"…"}` on stderr and exits with status 1.

- `request_ready` with `created: false`: an active request exists and is reused. Do not create another.
- `needs_admin_bootstrap`: none exists. Creating needs explicit approval for **one ONGOING request for this app**, naming the app and its App Store ID: the step-3A.3 confirmation, or a separate yes in section 3B. General setup consent or "go ahead with Apple" is not enough. Then call the companion again with `approve_create: true`, or append the bare flag `--approve-create-ongoing` (no value) to the command, using `bootstrap.json`.
- `request_ready` with `created: true`: done.

| Code | Meaning | What to do |
|---|---|---|
| `permission` | Apple refused: the key lacks the needed role (Admin to create; Sales and Reports or Admin to read), or an agreement is pending. The helper cannot tell which | Have the customer check the key's **Access** column and **Business** for pending agreements. Do not create another Admin key while one is active, and do not try other keys |
| `authentication` | Wrong Issuer ID or key ID, a revoked key, or a wrong system clock | Check the IDs against App Store Connect and the clock |
| `configuration` | Bad command or files: missing `--credentials`, an App Store ID that is not 5–20 digits, a flag with a value, a manifest with extra keys, an Issuer ID that is not a lowercase UUID, a key ID that is not 10 uppercase letters or digits, or a manifest or key file that is unreadable, a symlink, on a relative path, has group or other permission bits, or is not an Apple P-256 key | Check the command and manifest first, then the key file. Do not loosen permissions |
| `creation_status_unknown` | The create call may or may not have reached Apple | Run the read-only call first; never create twice |
| `request_conflict`, `ambiguous_request` | Apple reports a conflict or more than one active request | Report it; do not pick one or create a replacement |
| `rate_limited`, `transport`, `provider_response`, `invalid_response` | Apple or the network failed, or Apple sent an unexpected answer | Retry the read-only call later |

Once `InstallTally bootstrap` exists, never end the run with it active. If the request is not confirmed in this session (any error code, or the customer stops), revoke the key and delete `bootstrap.json` and its `.p8` before ending. A later attempt starts again with the reader check and a new temporary key.

## 5. Finish

1. Delete `reader-check.json` if it is still there. If InstallTally already held a reader (step 1.2), transfer nothing and resume the server task. Otherwise, if the reader was not handed over in step 3A.9, continue with [setup-app-store-reports](../setup-app-store-reports/SKILL.md) to package and transfer `InstallTally reports` privately (never a helper manifest). It selects the detailed downloads report (currently **App Downloads Detailed**) with daily data. Once InstallTally has it, ask whether to delete the local reader file too.
2. Tell the customer what happens next. Until Apple generates the first report instance, usually within one to two days, InstallTally shows the source enabled with no import jobs; that is expected, not an error. A new request is not a count of zero installs. Suggest checking again then with `doctor` or `setup-app-store-reports`, which verify the first import.
3. Report what ran, whether the request was reused or created, whether an Admin key was created and if so that it was revoked and deleted, and what the customer still has to do.

Never upload the Admin key to InstallTally, store it as the permanent reader, or create a second request.

References: [Creating API keys](https://developer.apple.com/documentation/appstoreconnectapi/creating-api-keys-for-app-store-connect-api), [Downloading analytics reports](https://developer.apple.com/documentation/appstoreconnectapi/downloading-analytics-reports), [Generating tokens](https://developer.apple.com/documentation/appstoreconnectapi/generating-tokens-for-api-requests).