---
title: "MakeAIVideo CLI and Device-Code Login for Terminals"
description: "Sign in to MakeAIVideo from a terminal with the device-code flow (RFC 8628) and get an API key onto a headless machine without pasting a secret into it."
canonical: https://makeaivideo.ai/docs/cli
format: markdown
generator: makeaivideo-marketing build-time HTML→MD
---

[Documentation](/docs)v1.2

Guides

-   [Overview](/docs)
-   [Quickstart](/docs/quickstart)
-   [Authentication](/docs/authentication)
-   [Webhooks](/docs/webhooks)

Integrations

-   [MCP server](/docs/mcp)
-   [Agents](/docs/agents)
-   [CLI](/docs/cli)
-   [TypeScript SDK](/docs/sdk)

API reference

-   [All endpoints](/docs/api)
-   [Introspection](/docs/api/introspection)
-   [Videos](/docs/api/videos)
-   [Scripts](/docs/api/scripts)
-   [Characters](/docs/api/characters)
-   [Voices](/docs/api/voices)
-   [Music](/docs/api/music)
-   [Uploads](/docs/api/uploads)
-   [Brand kit](/docs/api/brand-kit)
-   [Workspace](/docs/api/workspace)
-   [Ideas](/docs/api/ideas)
-   [Publishing](/docs/api/publishing)
-   [Webhooks](/docs/api/webhooks)
-   [Auth](/docs/api/auth)

# MakeAIVideo CLI and device login

Getting a key onto a machine that has no browser, without copying and pasting a secret around.

Install

```
npm install -g @makeaivideo/cli
```

Published on npm as [@makeaivideo/cli](https://www.npmjs.com/package/@makeaivideo/cli) with source on [GitHub](https://github.com/makeaivideo-ai/cli). Everything on this page also works with plain curl if you would rather not install anything, and the device-code endpoints below are the same ones the CLI calls.

## Device-code flow

Standard RFC 8628. The machine asks for a code, a human approves it in a browser somewhere else, and the machine collects the key. These two endpoints are the only unauthenticated ones in the API.

## 1\. Start a login

curlCopy

```
curl -X POST https://app.makeaivideo.ai/api/v1/auth/device \
  -H "Content-Type: application/json" \
  -d '{ "client_name": "my-laptop" }'
```

200 — field shapeCopy

```
{
  "data": {
    "device_code": "...",
    "user_code": "....-....",
    "verification_uri": "https://app.makeaivideo.ai/device",
    "verification_uri_complete": "https://app.makeaivideo.ai/device?code=...",
    "expires_in": <seconds>,
    "interval": <seconds between polls>
  },
  "error": null,
  "meta": { ... }
}
```

Show the user `user_code` and send them to `verification_uri`. If they are on the same machine, `verification_uri_complete` skips the typing.

## 2\. Poll for approval

Poll every `interval` seconds until the code expires.

curlCopy

```
curl -X POST https://app.makeaivideo.ai/api/v1/auth/device/token \
  -H "Content-Type: application/json" \
  -d '{ "device_code": "..." }'
```

status

What to do

pending

Nobody has approved it yet. Keep polling at the given interval.

slow\_down

You are polling too fast. Back off, then continue.

authorized

Approved. api\_key is present, once. Store it now.

denied

The user rejected the request. Stop.

expired

The code timed out. Start a new device login.

## 3\. Store the key

authorized — field shapeCopy

```
{
  "data": {
    "status": "authorized",
    "api_key": "mav_...",
    "api_key_id": <integer>
  },
  "error": null,
  "meta": { ... }
}
```

`api_key` is returned once and never again. Write it to your config or keychain on receipt. From there it is an ordinary bearer key, as described in [Authentication](/docs/authentication).

## CLI questions

Is there a MakeAIVideo CLI?

Yes. Install it with npm install -g @makeaivideo/cli. It signs in with the device-code flow, so no secret is ever pasted into a terminal, and everything it does is also possible with plain curl.

How do I log in from a server or a terminal?

Use the device-code flow. Request a code, approve it in a browser on any device, and your client polls until it receives the API key. Nobody has to paste a secret into the terminal.

Can I get the API key back if I lose it?

No. It is returned once on the authorized response and never again, so write it to your config or keychain immediately and issue a new key if it is lost.

## More MakeAIVideo documentation

In the product

-   [MakeAIVideo pricing](/pricing): plans and credit allowances

Specifications

-   [RFC 8628](https://datatracker.ietf.org/doc/html/rfc8628): the device authorization grant this flow implements

Get an API key

The API and MCP server use the same credits and the same balance as the app, with no separate API plan. Create a key under Settings, Advanced, API keys.

[Start 7 day free trial](https://app.makeaivideo.ai/signup?utm_source=docs&utm_medium=docs_cta&utm_content=%2Fdocs%2Fcli)[MakeAIVideo plans and pricing](/pricing)

7-day free trial with 350 credits, then plans from $9/mo. Cancel anytime before the trial ends.
