# Add callback URI to application

> **POST** `https://api.us.nylas.com/v3/applications/redirect-uris`

Source: https://developer.nylas.com/docs/reference/api/applications/add_callback_uri/

Adds a callback URI to the specified Nylas application. Nylas uses callback URIs to redirect users
to your project after they complete the authentication flow. If you don't specify a `platform`,
Nylas defaults to `web`.

The OAuth protocol requires that you include the `client_secret` field for calls made to this
endpoint, depending on the `platform` you define. If you're using
[OAuth 2.0 with PKCE](/docs/v3/auth/hosted-oauth-accesstoken/#create-grants-with-oauth-2.0-and-pkce)
and your platform is `js`, `ios`, `android`, or `desktop`, the `client_secret` field is not
required.

**Authentication:** NYLAS_API_KEY

## Request body

Content-Type: application/json

- **Web or Desktop**
- **JS**
- **iOS**
- **Android**

## Responses

### 200 - Returns callback URI

- `request_id` (string) - ID of the request
- `data` (any)
  - **Web or Desktop**
  - **JS**
  - **iOS**
  - **Android**

### 400 - Bad Request

- `request_id` (string) **(required)** - ID of the request
- `error` (object) **(required)** - Error object
  - `type` (string) - Type of error
  - `message` (string) - Informative error message
  - `provider_error` (object) - (OPTIONAL) informative error message from provider's side

### 401 - Not Authenticated

- `request_id` (string) **(required)** - ID of the request
- `error` (object) **(required)** - Error object
  - `type` (string) - Type of error
  - `message` (string) - Informative error message
  - `provider_error` (object) - (OPTIONAL) informative error message from provider's side

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.us.nylas.com/v3/applications/redirect-uris' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --data '{
    "platform": "web",
    "url": "<CALLBACK_URI>",
    "id": "<CALLBACK_URI_ID>"
  }'
```

### Node.js SDK

```javascript
import Nylas from "nylas";

const nylas = new Nylas({
  apiKey: "<NYLAS_API_KEY>",
  apiUri: "<NYLAS_API_URI>",
});

const redirectUri = await nylas.applications.redirectUris.create({
  requestBody: {
    url: "<CALLBACK_URI>",
    platform: "web",
  },
});

console.log("Redirect URI created:", redirectUri);

```

### Python SDK

```python
from nylas import Client

nylas = Client(
    "<NYLAS_API_KEY>",
    "<NYLAS_API_URI>",
)

redirect_uri = nylas.applications.redirect_uris.create(
    request_body={
        "url": "https://example.com/oauth/exchange",
        "platform": "web",
    },
)

print("Created redirect URI:", redirect_uri)

```

### Java SDK

```java
import com.nylas.NylasClient;
import com.nylas.models.CreateRedirectUriRequest;
import com.nylas.models.NylasApiError;
import com.nylas.models.NylasSdkTimeoutError;
import com.nylas.models.Platform;
import com.nylas.models.RedirectUri;
import com.nylas.models.Response;

public class CreateRedirectUri {
  public static void main(String[] args) throws NylasSdkTimeoutError, NylasApiError {
    NylasClient nylas = new NylasClient.Builder("<NYLAS_API_KEY>").build();

    CreateRedirectUriRequest requestBody = new CreateRedirectUriRequest.Builder(
        "<CALLBACK_URI>", Platform.WEB)
        .build();

    Response<RedirectUri> redirectUri = nylas.applications().redirectUris().create(requestBody);

    System.out.println("Redirect URI created: " + redirectUri.getData());
  }
}

```

### Kotlin SDK

```kotlin
import com.nylas.NylasClient
import com.nylas.models.CreateRedirectUriRequest
import com.nylas.models.Platform

fun main() {
  val nylas = NylasClient.Builder("<NYLAS_API_KEY>").build()

  val requestBody = CreateRedirectUriRequest.Builder("<CALLBACK_URI>", Platform.WEB)
      .build()

  val redirectUri = nylas.applications().redirectUris().create(requestBody)

  println("Redirect URI created: ${redirectUri.data}")
}

```
