# Create deployment event

POST https://app.launchdarkly.com/api/v2/engineering-insights/deployment-events
Content-Type: application/json

Create deployment event

Reference: https://launchdarkly.com/docs/api/insights-deployments-beta/create-deployment-event

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/engineering-insights/deployment-events:
    post:
      operationId: create-deployment-event
      summary: Create deployment event
      description: Create deployment event
      tags:
        - subpackage_insightsDeploymentsBeta
      parameters:
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Insights deployments
                  (beta)_createDeploymentEvent_Response_201
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationFailedErrorRep'
        '401':
          description: Invalid access token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedErrorRep'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenErrorRep'
        '404':
          description: Invalid resource identifier
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundErrorRep'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitedErrorRep'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostDeploymentEventInput'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    PostDeploymentEventInputApplicationKind:
      type: string
      enum:
        - server
        - browser
        - mobile
      description: 'The kind of application. Default: <code>server</code>'
      title: PostDeploymentEventInputApplicationKind
    PostDeploymentEventInputEventType:
      type: string
      enum:
        - started
        - failed
        - finished
        - custom
      description: The event type
      title: PostDeploymentEventInputEventType
    UnixMillis:
      type: integer
      format: int64
      title: UnixMillis
    PostDeploymentEventInput:
      type: object
      properties:
        projectKey:
          type: string
          description: The project key
        environmentKey:
          type: string
          description: The environment key
        applicationKey:
          type: string
          description: >-
            The application key. This defines the granularity at which you want
            to view your insights metrics. Typically it is the name of one of
            the GitHub repositories that you use in this
            project.<br/><br/>LaunchDarkly automatically creates a new
            application each time you send a unique application key.
        applicationName:
          type: string
          description: The application name. This defines how the application is displayed
        applicationKind:
          $ref: '#/components/schemas/PostDeploymentEventInputApplicationKind'
          description: 'The kind of application. Default: <code>server</code>'
        version:
          type: string
          description: >-
            The application version. You can set the application version to any
            string that includes only letters, numbers, periods
            (<code>.</code>), hyphens (<code>-</code>), or underscores
            (<code>_</code>).<br/><br/>We recommend setting the application
            version to at least the first seven characters of the SHA or to the
            tag of the GitHub commit for this deployment.
        versionName:
          type: string
          description: The version name. This defines how the version is displayed
        eventType:
          $ref: '#/components/schemas/PostDeploymentEventInputEventType'
          description: The event type
        eventTime:
          $ref: '#/components/schemas/UnixMillis'
          description: >-
            The time, in Unix milliseconds, when the event occurred. If not
            included, the time will default to when the event is processed and
            stored in LaunchDarkly.
        eventMetadata:
          type: object
          additionalProperties:
            description: Any type
          description: A JSON object containing metadata about the event
        deploymentMetadata:
          type: object
          additionalProperties:
            description: Any type
          description: A JSON object containing metadata about the deployment
      required:
        - projectKey
        - environmentKey
        - applicationKey
        - version
        - eventType
      title: PostDeploymentEventInput
    Insights deployments (beta)_createDeploymentEvent_Response_201:
      type: object
      properties: {}
      description: Empty response body
      title: Insights deployments (beta)_createDeploymentEvent_Response_201
    FailureReasonRep:
      type: object
      properties:
        attribute:
          type: string
          description: The attribute that failed validation
        reason:
          type: string
          description: The reason the attribute failed validation
      required:
        - attribute
        - reason
      title: FailureReasonRep
    ValidationFailedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
        errors:
          type: array
          items:
            $ref: '#/components/schemas/FailureReasonRep'
          description: List of validation errors
      required:
        - code
        - message
        - errors
      title: ValidationFailedErrorRep
    UnauthorizedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: UnauthorizedErrorRep
    ForbiddenErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: ForbiddenErrorRep
    NotFoundErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: NotFoundErrorRep
    RateLimitedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: RateLimitedErrorRep
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

```

## SDK Code Examples

```python
import requests

url = "https://app.launchdarkly.com/api/v2/engineering-insights/deployment-events"

payload = {
    "projectKey": "default",
    "environmentKey": "production",
    "applicationKey": "billing-service",
    "version": "a90a8a2",
    "eventType": "started"
}
headers = {
    "Authorization": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://app.launchdarkly.com/api/v2/engineering-insights/deployment-events';
const options = {
  method: 'POST',
  headers: {Authorization: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"projectKey":"default","environmentKey":"production","applicationKey":"billing-service","version":"a90a8a2","eventType":"started"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://app.launchdarkly.com/api/v2/engineering-insights/deployment-events"

	payload := strings.NewReader("{\n  \"projectKey\": \"default\",\n  \"environmentKey\": \"production\",\n  \"applicationKey\": \"billing-service\",\n  \"version\": \"a90a8a2\",\n  \"eventType\": \"started\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.launchdarkly.com/api/v2/engineering-insights/deployment-events")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"projectKey\": \"default\",\n  \"environmentKey\": \"production\",\n  \"applicationKey\": \"billing-service\",\n  \"version\": \"a90a8a2\",\n  \"eventType\": \"started\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://app.launchdarkly.com/api/v2/engineering-insights/deployment-events")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"projectKey\": \"default\",\n  \"environmentKey\": \"production\",\n  \"applicationKey\": \"billing-service\",\n  \"version\": \"a90a8a2\",\n  \"eventType\": \"started\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.launchdarkly.com/api/v2/engineering-insights/deployment-events', [
  'body' => '{
  "projectKey": "default",
  "environmentKey": "production",
  "applicationKey": "billing-service",
  "version": "a90a8a2",
  "eventType": "started"
}',
  'headers' => [
    'Authorization' => '<apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/engineering-insights/deployment-events");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"projectKey\": \"default\",\n  \"environmentKey\": \"production\",\n  \"applicationKey\": \"billing-service\",\n  \"version\": \"a90a8a2\",\n  \"eventType\": \"started\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "projectKey": "default",
  "environmentKey": "production",
  "applicationKey": "billing-service",
  "version": "a90a8a2",
  "eventType": "started"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://app.launchdarkly.com/api/v2/engineering-insights/deployment-events")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```