# Deployment Events API

The Deployment Events API lets you track deployment activity (started and completed) for your organization. These events are used to calculate DORA metrics such as deployment frequency and change failure rate.<br>

### 1. Base URLs

The base URL for accessing Hivel may vary depending on your organization's configuration. Please make sure to select the appropriate base URL according to your setup.

The URL will be either of these:

**`https://app.hivel.ai`** OR **`https://app.hivel.in`**

### 2. Authentication

All API requests require an Organization API Key.

Headers:

| <p><strong>X-API-Token</strong>: YOUR\_API\_KEY<br><strong>Content-Type</strong>: application/json</p> |
| ------------------------------------------------------------------------------------------------------ |

#### How to Retrieve Your API Key:

1. Open the Hivel application and navigate to Integrations under Settings.
2. Click on Connect on Deployment API card
   1\.

   ```
   <figure><img src="https://3057781534-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5KAIOUWph0JLSgQqbzyT%2Fuploads%2Fr61m7DRU3RaOj7GIzM0t%2Fimage.png?alt=media&#x26;token=5f6f1747-7bb6-4dd2-a4b2-4f6fbc824c82" alt="" width="374"><figcaption></figcaption></figure>
   ```
3. Follow steps to Generate API key.
   1\.

   ```
   <figure><img src="https://3057781534-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5KAIOUWph0JLSgQqbzyT%2Fuploads%2FgVQKHE1sREqt7K6sV2jM%2Fimage.png?alt=media&#x26;token=50b414f5-f008-4475-88b1-7e16a25c2e4e" alt="" width="375"><figcaption></figcaption></figure>
   ```

### 3. API Overview

|            Model           |            Endpoint           |                                     Use Case                                     |
| :------------------------: | :---------------------------: | :------------------------------------------------------------------------------: |
| v2 – Single Event Workflow | POST /api/hooks/v2/deployment | CI/CD sends one event after finishing, containing both start and end timestamps. |

* v2 emits a single event after finishing your CI/CD job.

### 4. Required Fields

#### v2 (Single event: completed)

{% hint style="info" %}
**Note**: Hivel calculates duration as end\_time - start\_time.
{% endhint %}

|      Field     | Required |                                                                                                                                                        Notes                                                                                                                                                       |
| :------------: | :------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| deployment\_id |    Yes   |                                                                                                                                                   Must be unique.                                                                                                                                                  |
|   event\_type  |    Yes   |                                                                                                                                                Must be "completed".                                                                                                                                                |
|     status     |    Yes   |                                                                                                                                     "success", "failed", "cancelled", "unknown"                                                                                                                                    |
|   start\_time  |    Yes   |                                                                                                                                             Deployment start timestamp.                                                                                                                                            |
|    end\_time   |    Yes   |                                                                                                                                              Deployment end timestamp.                                                                                                                                             |
|    repo\_url   |    Yes   | <p>Git repo URL.<br><br>e.g Web URL (or HTML URL): <a href="https://github.com/hivelai/webhook-logger"><code><https://github.com/hivelai/webhook-logger></code></a><br>Git Clone URL: <a href="https://github.com/hivelai/webhook-logger.git"><code><https://github.com/hivelai/webhook-logger.git></code></a></p> |
|   environment  |    Yes   |                                                                                                                                  production / staging / dev / etc (string value).                                                                                                                                  |
|     branch     |    Yes   |                                                                                                                                       Branch name on which CI/CD is running.                                                                                                                                       |
|  commit\_hash  |    No    |                                                                                                                                                 Yes, if available.                                                                                                                                                 |
|   pr\_number   |    No    |                                                                                                                                                 Yes, if available.                                                                                                                                                 |
|   pr\_numbers  |    No    |                                                                                                                                                 Yes, if available.                                                                                                                                                 |
|  build\_number |    No    |                                                                                                                                                 Optional metadata.                                                                                                                                                 |
|      image     |    No    |                                                                                                                                                 Optional metadata.                                                                                                                                                 |
|    logs\_url   |    No    |                                                                                                                                                 Optional metadata.                                                                                                                                                 |

### 5. Accepted Timestamp Formats

Hivel accepts all common timestamp formats:

* **ISO / RFC 3339**
  * 2025-11-19T10:20:32Z
  * 2025-11-19T10:20:32.846Z
* **Epoch**
  * Seconds: 1700385632
  * Milliseconds: 1700385632846

### 6. Status Normalization

Hivel simplifies pipeline status tracking by automatically mapping your custom status strings into four standardized values (`success`, `failed`, `canceled`, `unknown`).

{% hint style="success" %}
💡 **Key Takeaway**: Just send whatever status your CI/CD reports - Hivel will automatically translate it into the four standard values shown below. If you prefer to handle the translation logic yourself before sending the data, that works too.
{% endhint %}

#### Mapping Reference

| Provider           | Status Mapping Logic                                                                                                                                                                                                                                                                                                                                                 |                                                                                                                                                    |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| Jenkins            | <p>• <code>SUCCESS</code> → <strong>success</strong></p><p>• <code>FAILURE</code>, <code>UNSTABLE</code> → <strong>failed</strong></p><p>• <code>ABORTED</code> → <strong>canceled</strong></p><p>• <code>NOT\_BUILT</code> → <strong>unknown</strong></p>                                                                                                           |                                                                                                                                                    |
| GitHub Actions     | <p>• <code>success</code> → <strong>success</strong></p><p>• <code>failure</code>, <code>timed\_out</code> → <strong>failed</strong></p><p>• <code>canceled</code> → <strong>canceled</strong></p><p>• <code>neutral</code>, <code>skipped</code>, <code>stale</code>, <code>action\_required</code> (or other non-terminal statuses) → <strong>unknown</strong></p> |                                                                                                                                                    |
| GitLab CI          | <p>• <code>success</code> → <strong>success</strong></p><p>• <code>failed</code> → <strong>failed</strong></p><p>• <code>canceled</code> → <strong>canceled</strong></p><p>• <code>manual</code>, <code>skipped</code>, <code>pending</code>, <code>running</code> → <strong>unknown</strong></p>                                                                    |                                                                                                                                                    |
| CircleCI           | <p>• <code>success</code> → <strong>success</strong></p><p>• <code>failed</code>, <code>timedout</code>, <code>infrastructure\_fail</code> → <strong>failed</strong></p><p>• <code>canceled</code> → <strong>canceled</strong></p><p>• <code>not\_run</code>, <code>on\_hold</code>, <code>queued</code>, <code>running</code> → <strong>unknown</strong></p>        |                                                                                                                                                    |
| Argo Workflows     | <p>• <code>Succeeded</code> → <strong>success</strong></p><p>• <code>Failed</code>, <code>Error</code> → <strong>failed</strong></p><p>• <code>Skipped</code>, <code>Omitted</code> (or non-terminal like Pending, Running) → <strong>unknown</strong></p>                                                                                                           |                                                                                                                                                    |
| Azure DevOps       | <p>• <code>succeeded</code> → <strong>success</strong></p><p>• <code>failed</code> → <strong>failed</strong></p><p>• <code>canceled</code> → <strong>canceled</strong></p><p>• <code>partiallySucceeded</code>, <code>succeededWithIssues</code> → <strong>unknown</strong></p>                                                                                      |                                                                                                                                                    |
| ArgoCD             | <p><code>operationState.phase</code> = Succeeded<br>health.status = Healthy</p><p>→ status = success</p><p></p><p><code>phase</code> = Failed                                                                                                                                                                                                                        | Error OR <code>health</code> = Degraded</p><p>→ status = failed</p><p><br>Running / Progressing / Missing / Suspended</p><p>→ status = unknown</p> |
| Any other provider | • Default → unknown                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                    |

### 7. Common CI/CD Field Mapping

Use the following variables to populate the Deployment Events API payload in your CI/CD workflow.

Values may differ depending on your tool version, runner type, or plugin, so always verify using your platform’s official documentation.

<table><thead><tr><th align="center">Field</th><th align="center">GitHub Actions</th><th align="center">GitLab CI</th><th align="center">Jenkins</th><th align="center">Azure DevOps</th><th width="291.3699951171875">ArgoCD</th></tr></thead><tbody><tr><td align="center">repo_url</td><td align="center">${{ github.repository }}</td><td align="center">$CI_PROJECT_URL</td><td align="center">$GIT_URL</td><td align="center">$(Build.Repository.Uri)</td><td>spec.source.repoURL</td></tr><tr><td align="center">commit_hash</td><td align="center">${{ github.sha }}</td><td align="center">$CI_COMMIT_SHA</td><td align="center">$GIT_COMMIT</td><td align="center">$(Build.SourceVersion)</td><td>status.sync.revision</td></tr><tr><td align="center">environment</td><td align="center">${{ github.environment }}</td><td align="center">$CI_ENVIRONMENT_NAME</td><td align="center">$ENVIRONMENT</td><td align="center">$(Release.EnvironmentName)</td><td>You define this - Typically: <code>spec.destination.name</code> or <code>spec.destination.namespace</code></td></tr><tr><td align="center">start_time</td><td align="center"><p>Step output</p><p><br></p><p>(e.g. steps.start.outputs.time)</p></td><td align="center">$CI_JOB_STARTED_AT</td><td align="center">$BUILD_ID / plugin timestamps</td><td align="center">$(Build.StartTime)</td><td>status.operationState.startedAt</td></tr><tr><td align="center">end_time</td><td align="center">Workflow end timestamp</td><td align="center">$CI_JOB_FINISHED_AT</td><td align="center">Timestamp + duration</td><td align="center">$(Build.FinishTime)</td><td>status.operationState.finishedAt</td></tr><tr><td align="center">deployment_id</td><td align="center">-</td><td align="center">-</td><td align="center">-</td><td align="center">-</td><td><code>metadata.name</code> or <code>metadata.uid</code></td></tr><tr><td align="center">status</td><td align="center">-</td><td align="center">-</td><td align="center">-</td><td align="center">-</td><td>Computed from <code>status.operationState.phase</code> + <code>status.health.status</code></td></tr><tr><td align="center">event_type</td><td align="center">-</td><td align="center">-</td><td align="center">-</td><td align="center">-</td><td>completed</td></tr><tr><td align="center">logs_url</td><td align="center">-</td><td align="center">-</td><td align="center">-</td><td align="center">-</td><td>Optional: Argo CD UI link - e.g., <code>https://argocd.example.com/applications/&#x3C;app-name></code></td></tr></tbody></table>

{% hint style="info" %}

#### **⚠️ Important Notes**

* **Platform Variations:** These mappings may not work exactly for every CI/CD platform, runner, or plugin version you are using. Always consult the official documentation for your specific environment.
* **Custom Variables:** If a required field isn’t directly available, simply define an environment variable (e.g., DEPLOYMENT\_ID, START\_TIME) early in your pipeline and reuse it in the final API call.
* **Timestamp Handling:** The mechanism to capture timestamps varies widely across platforms (e.g., GitHub custom actions, Jenkins plugins, Azure job context). Pick the most reliable approach for your specific setup.
  {% endhint %}

***

### 8. How to Send Events

You can send the event using:

1. **Inline Script**: curl from shell, or PowerShell Invoke-RestMethod.
2. **Platform Webhooks**: GitLab Integrations, GitHub Webhooks, or Argo Notifications.

**Security Note**: Store the API token in your CI/CD secrets manager. Do not hardcode it in plain text.

### 9. Example Requests

#### v2 – Single Completed Event

**Note**: timestamp is replaced by start\_time and end\_time.

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><pre class="language-javascript"><code class="lang-javascript">curl -X POST https://app.hivel.ai/api/hooks/v2/deployment \
  -H "X-API-Token: YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "deployment_id": "deploy-20250922-1200",
    "event_type": "completed",
    "status": "success",
    "repo_url": "https://github.com/hivelai/webhook-logger",
    "commit_hash": "abc123def456789012345678901234567890abcd",
    "environment": "production",
    "start_time": "2025-09-22T12:00:00Z",
    "end_time": "2025-09-22T12:15:30Z",
    "branch": "main",
    "build_number": "12345",
    "pr_number": "71",
    "pr_numbers": [71,35,23],
    "image": "company/api-service:v1.2.3",
    "logs_url": "https://logs.example.com/deploy/20250922-1200"
  }'
</code></pre></td></tr></tbody></table>

### 10. Example Responses

**Success:**

| <p>{<br>  "message": "Deployment event stored successfully",<br>  "deployment\_id": "deploy-20250922-1200",<br>  "success": true<br>}</p> |
| ----------------------------------------------------------------------------------------------------------------------------------------- |

**Validation Error:**

| <p>{<br>  "message": "Validation failed",<br>  "error": "Start time cannot be after end time"<br>}</p> |
| ------------------------------------------------------------------------------------------------------ |

### 11. Recommended Usage Flow

1. Generate API token in Hivel Settings.
2. Extract fields (repo, commit, timestamp) from your CI/CD environment variables.
3. Send POST request via your pipeline configuration.

Hivel processes the data to update DORA metrics automatically.
