> ## Documentation Index
> Fetch the complete documentation index at: https://docs.titanos.tv/llms.txt
> Use this file to discover all available pages before exploring further.

# App Control

### Introduction

**App Control** enables seamless integration of deep-linking and app control functions for partners. This documentation outlines the method's syntax, parameters, and behavior for launching applications on Titan OS.

### Getting Started

To use the App Control API, you must include the following script in your application:

```html theme={null}
<script
  src="https://app.titanos.tv/app2app/bridge.umd.js"
  type="text/javascript"
/>
```

### Syntax

```typescript theme={null}
TitanOS.launchApp(code: string, query?:string): Promise<void>
```

### Parameters

* `code` (string, required): The universal identifier of the application to be launched. Example: `netflix`, `primevideo`, `youtube`, etc. You can find these codes in the Partner Portal under the **Resources -> [App Control](https://partners.titanos.tv/partners/app-control)** section.
* `query` (string, optional): A deeplink or query string unique to each app, passed to the application upon launching. This can be used to navigate to specific content within the app.

### Behavior

1. Application Validation: With the App code, we validate if the app exists and is available in the user's current country market and TV model.
2. Launching the Application:
   * Success: If the application is valid and available, it is launched with the optional `query`. The promise resolves successfully.
   * Failure: If the application is not valid or unavailable, the promise is rejected with a specific error code.

### Error Handling

The promise may be rejected with an error object containing:

* `code` (string): A machine-readable error code indicating the type of error.
* `message` (string): A human-readable message providing more details about the error.

### Error Codes

* `APP_NOT_FOUND`: The application specified by `code` does not exist.

### Example Usage

```javascript theme={null}
// Launching an app without query
TitanOS.launchApp("netflix")
  .then(() => {
    console.log("Netflix launched successfully.");
  })
  .catch((error) => {
    console.error(`Error (${error.code}): ${error.message}`);
  });

// Launching an app with query or deeplink
TitanOS.launchApp("youtube", "https://youtu.be/dQw4w9WgXcQ")
  .then(() => {
    console.log("YouTube launched with the specified video.");
  })
  .catch((error) => {
    console.error(`Error (${error.code}): ${error.message}`);
  });
```
