# Agency Read Campaign By Id

API URI

```
https://api.versal.one/<uuid>
```

```
GET /agency/getCampaign/<campaign id>
```

#### **Description**

This API allows fetching campaign details by providing the campaign `id` and the `uuid` of the company. The endpoint returns campaign data if found, otherwise, a message indicating no data found.

---

#### **Request Headers**

<table id="bkmrk-header-type-descript"><thead><tr><th>Header</th><th>Type</th><th>Description</th><th>Constraints</th></tr></thead><tbody><tr><td>`Authorization`</td><td>String</td><td>JWT token for user authentication and authorization.</td><td>Required. Must be in the format `Bearer [token]`.</td></tr></tbody></table>

---

#### **Request Parameters**

<table id="bkmrk-field-type-descripti"><thead><tr><th>Field</th><th>Type</th><th>Description</th><th>Constraints</th></tr></thead><tbody><tr><td>`id`</td><td>String</td><td>ID of the campaign to fetch.</td><td>Required.</td></tr><tr><td>`uuid`</td><td>String</td><td>UUID of the company or user associated with the campaign.</td><td>Required.</td></tr></tbody></table>

---

#### **Response Codes**

<table id="bkmrk-status-code-descript"><thead><tr><th>Status Code</th><th>Description</th></tr></thead><tbody><tr><td>`200`</td><td>Success. Campaign data retrieved successfully.</td></tr><tr><td>`204`</td><td>No Content. No campaign found for the provided ID.</td></tr><tr><td>`400`</td><td>Bad Request. Campaign ID is required.</td></tr><tr><td>`401`</td><td>Unauthorized. Invalid or missing JWT token.</td></tr><tr><td>`404`</td><td>Not Found. No company found with the provided UUID or no campaign found with the ID.</td></tr><tr><td>`500`</td><td>Internal Server Error. An unexpected error occurred while fetching the campaign data.</td></tr><tr><td>`403`</td><td>Forbidden. Invalid HMAC signature.</td></tr></tbody></table>

---

#### **Example Requests**

**Request (Get Campaign):**

```json

GET 53d1bcd3-aaf0-45e1-9298-5395b6a27b61/agency/getCampaign/12345
Authorization: Bearer 5395b6a27b61

```

**Response (Campaign Found - 200):**

```json

{
  "success": true,
  "message": "Successfully fetched campaign data.",
  "data": [
    {
      "id": "12345",
      "uuid": "53d1bcd3-aaf0-45e1-9298-5395b6a27b61",
      "name": "Campaign Name",
      "status": "active",
      "startDate": "2025-01-01",
      "endDate": "2025-12-31"
    }
  ]
}

```


**Response (No Campaign Found - 204):**

```json

{
  "success": true,
  "message": "No campaign data found.",
  "data": []
}

```


**Response (Missing Campaign ID - 400):**

```json

{
  "success": false,
  "message": "Campaign ID is required."
}

```


**Response (No Company Found - 404):**

```json

{
  "success": false,
  "message": "No company found with the provided uuid"
}

```


**Response (Internal Server Error - 500):**

```json

{
  "success": false,
  "message": "An unexpected error occurred while fetching the campaign by id. Please try again later."
}

```


**Response (Invalid HMAC Signature - 403):**

```json

{
  "success": false,
  "message": "Forbidden: Invalid HMAC signature"
}

```


---

#### **Notes**

- **Authentication**: Ensure the JWT token is valid and authorized to access campaign data.
- **Validation**: Both `id` and `uuid` are required. Missing any of these will result in a 400 or 404 error.
- **Error Handling**: For any server errors (500), check the logs for detailed error information.