# Create an application

Creates a new error tracking application.

[endpoint]
base_url = "https://errors.betterstack.com"
path = "/api/v1/applications"
method = "POST"

[[body_param]]
name = "name"
description = "Application name. Must be unique within your team."
required = true
type = "string"

[[body_param]]
name = "platform"
description = "The platform type for the application. This helps configure appropriate SDKs and integrations. <br>The currently supported platforms are: <br>- `aiohttp_errors`<br>- `android_errors`<br>- `angular_errors`<br>- `asgi_errors`<br>- `asp_dot_net_core_errors`<br>- `asp_dot_net_errors`<br>- `astro_errors`<br>- `aws_lambda_dot_net_errors`<br>- `aws_lambda_node_errors`<br>- `aws_lambda_python_errors`<br>- `azure_functions_node_errors`<br>- `bottle_errors`<br>- `bun_errors`<br>- `celery_errors`<br>- `chalice_errors`<br>- `cli_errors`<br>- `cloudflare_pages_errors`<br>- `connect_errors`<br>- `dart_errors`<br>- `deno_errors`<br>- `django_errors`<br>- `dot_net_errors`<br>- `dot_net_http_errors`<br>- `dot_net_maui_errors`<br>- `echo_errors`<br>- `electron_errors`<br>- `elixir_errors`<br>- `ember_errors`<br>- `express_errors`<br>- `falcon_errors`<br>- `fastapi_errors`<br>- `fasthttp_errors`<br>- `fastify_errors`<br>- `fiber_errors`<br>- `flask_errors`<br>- `flutter_errors`<br>- `gatsby_errors`<br>- `gin_errors`<br>- `go_errors`<br>- `godot_errors`<br>- `google_cloud_function_dot_net_errors`<br>- `google_cloud_function_node_errors`<br>- `google_cloud_function_python_errors`<br>- `hapi_errors`<br>- `ios_errors`<br>- `iris_errors`<br>- `java_errors`<br>- `javascript_errors`<br>- `koa_errors`<br>- `kotlin_errors`<br>- `laravel_errors`<br>- `log4j_errors`<br>- `logback_errors`<br>- `macos_errors`<br>- `minidump_errors`<br>- `native_errors`<br>- `negroni_errors`<br>- `nest_js_errors`<br>- `next_js_errors`<br>- `node_errors`<br>- `nuxt_errors`<br>- `php_errors`<br>- `powershell_errors`<br>- `pyramid_errors`<br>- `python_errors`<br>- `qt_errors`<br>- `quart_errors`<br>- `rack_middleware_errors`<br>- `rails_errors`<br>- `react_errors`<br>- `react_native_errors`<br>- `react_router_framework_errors`<br>- `remix_errors`<br>- `rq_errors`<br>- `ruby_errors`<br>- `rust_errors`<br>- `sanic_errors`<br>- `serverless_python_errors`<br>- `solid_errors`<br>- `solidstart_errors`<br>- `spring_boot_errors`<br>- `spring_errors`<br>- `starlette_errors`<br>- `svelte_errors`<br>- `sveltekit_errors`<br>- `symfony_errors`<br>- `tanstack_start_react_errors`<br>- `tornado_errors`<br>- `tryton_errors`<br>- `unity_errors`<br>- `unreal_engine_errors`<br>- `vue_errors`<br>- `windows_forms_errors`<br>- `wpf_errors`<br>- `wsgi_errors`"
required = true
type = "string"

[[body_param]]
name = "data_region"
description = "Data region or cluster name where application data will be stored. If omitted, the default data region for your team will be used (e.g., `us-east-9`)."
required = false
type = "string"

[[body_param]]
name = "errors_retention"
description = "Error data retention period in days. Default retention is 90 days."
required = false
type = "integer"

[[body_param]]
name = "application_group_id"
description = "ID of the application group this application belongs to."
required = false
type = "string"

[[body_param]]
name = "code_mapping_stack_root"
description = "The absolute path to the root of the stack trace on your server (e.g., `/usr/src/app/`). This is used to resolve source code paths for AI-assisted debugging."
required = false
type = "string"

[[body_param]]
name = "code_mapping_source_root"
description = "The relative path from your project's root to the source code being deployed (e.g., `apps/backend/`). This is used to resolve source code paths for AI-assisted debugging."
required = false
type = "string"

[[header]]
name = "Authorization"
description = "Bearer `$TOKEN`"
required = true
type = "string"

[[header]]
name = "Content-Type"
description = "application/json"
required = true
type = "string"
[/endpoint]

[responses]
[[response]]
status = 201
description = '''Returns the newly created application.'''
body = '''{
  "data": {
    "id": "1234",
    "type": "application",
    "attributes": {
      "application_group_id": null,
      "team_id": 123456,
      "team_name": "example-team",
      "name": "new-web-app",
      "table_name": "new_web_app",
      "token": "abc123def456ghi789",
      "ingesting_paused": false,
      "ingesting_host": "s1234.us-east-9.betterstackdata.com",
      "created_at": "2025-01-15T10:30:00.000Z",
      "updated_at": "2025-01-15T10:30:00.000Z",
      "errors_retention": 90,
      "data_region": "us-east-9",
      "custom_bucket": null,
      "code_mapping_stack_root": "/usr/src/app/",
      "code_mapping_source_root": "apps/backend/"
    }
  }
}'''

[[response]]
status = 401
description = '''Unauthorized'''
body = '''{
  "errors": "Invalid authentication"
}'''

[[response]]
status = 400
description = '''Bad Request - Missing Required Attributes'''
body = '''{
  "errors": "Sorry, you are missing some required attributes",
  "required_attributes": ["name", "platform"]
}'''

[[response]]
status = 422
description = '''Unprocessable Entity - Validation Errors'''
body = '''{
  "errors": ["platform must be suffixed with \"_errors\" for Errors applications"],
  "invalid_attributes": ["platform"]
  }
}'''
[/responses]

#### Example cURL

```shell
[label Example]
curl --request POST \
  --url https://errors.betterstack.com/api/v1/applications \
  --header "Authorization: Bearer $TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "new-web-app",
    "platform": "ruby_errors",
    "errors_retention": 90,
    "data_region": "us-east-9",
    "code_mapping_stack_root": "/usr/src/app/",
    "code_mapping_source_root": "apps/backend/"
  }'
```
