> ## Documentation Index
> Fetch the complete documentation index at: https://docs.commvoice.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# sms.campaigns.reports

> Examples:
- **Getting clicks, sent count per campaign**
request:
```json
{
"rowGroupCols": [
{
"field": "campaign_id"
}
]
}
```

response:
```json
{
"data": [
{
...
"campaign_id": "2bdb6f47-ac08-34b8-9c89-6497b3be237f",
"is_sent": "4",
"is_clicked": "0",
...
},
"meta": { ... }
}
```

- **Getting clicks, sent count per country**
request:
```json
{
"rowGroupCols": [
{
"field": "country_id"
}
]
}
```

response:
```json
{
"data": [
{
...
"country_id": 226,
"is_sent": "4",
"is_clicked": "0",
...
},
"meta": { ... }
}
```

- **Group per hour/date/year-week, year-month**

Use `show_as` to specify the group type
DateTime columns can be group by `hour`, `date`, `year-week`, `year-month`

example:
```json
{
"rowGroupCols": [
{
"field": "sent_at",
"show_as": "date"
}
]
}
```

response:
```json
{
"data": [
{
...
"sent_at": "2023-08-03",
"is_sent": "230",
"is_clicked": "25",
"is_lead": "0",
"is_sale": "0",
"ctr": 10.87,
...
},
```

- **Group by multiple columns**

Use `groupByAll` to group by all columns that are in rowGroupCols

example:
```json
{
"rowGroupCols": [
{
"field": "sent_at",
"show_as": "date"
},
{
"field": "country_id"
}
],
"groupByAll": true
}
```

response:
```json
{
"data": [
{
...
"sent_at": "2023-08-03",
"country_id": 226,
"is_sent": "210",
"is_clicked": "25",
"is_lead": "0",
"is_sale": "0",
"ctr": 11.9,
...
"sent_at": "2023-08-03",
"country_id": 13,
"is_sent": "20",
"is_clicked": "0",
"is_lead": "0",
"is_sale": "0",
"ctr": 0,
...
},
```
without `groupByAll` parameter the response will be grouped by the first column in `rowGroupCols`.  .
usually this response is used for the AG-grid component:
```
| sent_at ______ | country_id | is_sent | is_clicked | ctr __ |
| -------------- | ---------- | ------- | ---------- | ------ |
| [+] 2023-08-03 | 2 ________ | 230 ___ | 25 _______ | 11.9 _ |
```
after this the user can expand the row and see the data for each country:
```
| sent_at ______ | country_id __ | is_sent | is_clicked | ctr_ |
--------------------------------------------------------------- |
| [-] 2023-08-03 | 2 ___________ | 230 ___ | 25 _______ | 11.9 |
--------------------------------------------------------------- |
| ______________ | 226 _________ | 210 ___ | 25 _______ | 11.9 |
--------------------------------------------------------------- |
| ______________ | 13 __________ | 20 ____ | 0 ________ | 0 __ |
```



## OpenAPI

````yaml https://api.comm.com/docs/api.json post /v1/sms/campaigns/reports
openapi: 3.1.0
info:
  title: Commvoice API
  version: '1'
servers:
  - url: https://api.comm.com/api
    description: Live
security:
  - http: []
paths:
  /v1/sms/campaigns/reports:
    post:
      tags:
        - SmsCampaigns
      summary: sms.campaigns.reports
      description: >-
        Examples:

        - **Getting clicks, sent count per campaign**

        request:

        ```json

        {

        "rowGroupCols": [

        {

        "field": "campaign_id"

        }

        ]

        }

        ```


        response:

        ```json

        {

        "data": [

        {

        ...

        "campaign_id": "2bdb6f47-ac08-34b8-9c89-6497b3be237f",

        "is_sent": "4",

        "is_clicked": "0",

        ...

        },

        "meta": { ... }

        }

        ```


        - **Getting clicks, sent count per country**

        request:

        ```json

        {

        "rowGroupCols": [

        {

        "field": "country_id"

        }

        ]

        }

        ```


        response:

        ```json

        {

        "data": [

        {

        ...

        "country_id": 226,

        "is_sent": "4",

        "is_clicked": "0",

        ...

        },

        "meta": { ... }

        }

        ```


        - **Group per hour/date/year-week, year-month**


        Use `show_as` to specify the group type

        DateTime columns can be group by `hour`, `date`, `year-week`,
        `year-month`


        example:

        ```json

        {

        "rowGroupCols": [

        {

        "field": "sent_at",

        "show_as": "date"

        }

        ]

        }

        ```


        response:

        ```json

        {

        "data": [

        {

        ...

        "sent_at": "2023-08-03",

        "is_sent": "230",

        "is_clicked": "25",

        "is_lead": "0",

        "is_sale": "0",

        "ctr": 10.87,

        ...

        },

        ```


        - **Group by multiple columns**


        Use `groupByAll` to group by all columns that are in rowGroupCols


        example:

        ```json

        {

        "rowGroupCols": [

        {

        "field": "sent_at",

        "show_as": "date"

        },

        {

        "field": "country_id"

        }

        ],

        "groupByAll": true

        }

        ```


        response:

        ```json

        {

        "data": [

        {

        ...

        "sent_at": "2023-08-03",

        "country_id": 226,

        "is_sent": "210",

        "is_clicked": "25",

        "is_lead": "0",

        "is_sale": "0",

        "ctr": 11.9,

        ...

        "sent_at": "2023-08-03",

        "country_id": 13,

        "is_sent": "20",

        "is_clicked": "0",

        "is_lead": "0",

        "is_sale": "0",

        "ctr": 0,

        ...

        },

        ```

        without `groupByAll` parameter the response will be grouped by the first
        column in `rowGroupCols`.  .

        usually this response is used for the AG-grid component:

        ```

        | sent_at ______ | country_id | is_sent | is_clicked | ctr __ |

        | -------------- | ---------- | ------- | ---------- | ------ |

        | [+] 2023-08-03 | 2 ________ | 230 ___ | 25 _______ | 11.9 _ |

        ```

        after this the user can expand the row and see the data for each
        country:

        ```

        | sent_at ______ | country_id __ | is_sent | is_clicked | ctr_ |

        --------------------------------------------------------------- |

        | [-] 2023-08-03 | 2 ___________ | 230 ___ | 25 _______ | 11.9 |

        --------------------------------------------------------------- |

        | ______________ | 226 _________ | 210 ___ | 25 _______ | 11.9 |

        --------------------------------------------------------------- |

        | ______________ | 13 __________ | 20 ____ | 0 ________ | 0 __ |

        ```
      operationId: sms.campaigns.reports
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                sortModel:
                  type: array
                  example:
                    - sort: asc
                      colId: updated_datetime
                  prefixItems:
                    - $ref: >-
                        #/components/schemas/App.Domain.Campaigns.Data.Reports.Sendlogs.SortModelData
                  minItems: 1
                  maxItems: 1
                  additionalItems: false
                filterModel:
                  type: array
                  example: >-
                    {"is_sent":{"filterType":"number","type":"greaterThan","filter":5}}


                    note that it needs to be col_id: {FilterModel}, PHP doesn't
                    support this kind of description.
                  prefixItems:
                    - type: array
                      prefixItems:
                        - $ref: '#/components/schemas/FilterModelData'
                      minItems: 1
                      maxItems: 1
                      additionalItems: false
                  minItems: 1
                  maxItems: 1
                  additionalItems: false
                rowGroupCols:
                  type: array
                  example:
                    - id: campaign_id
                      displayName: Campaign_Id
                      field: campaign_id
                  prefixItems:
                    - $ref: '#/components/schemas/SmsSendlogRowGroupColsData'
                  minItems: 1
                  maxItems: 1
                  additionalItems: false
                groupKeys:
                  type: array
                  example: |-
                    ["campaign_uuid"]
                    Not the column type, it's a filter of the query
                  prefixItems:
                    - type: string
                  minItems: 1
                  maxItems: 1
                  additionalItems: false
                selectCols:
                  type: array
                  prefixItems:
                    - $ref: '#/components/schemas/SmsSendLogFieldEnum'
                  minItems: 1
                  maxItems: 1
                  additionalItems: false
                startRow:
                  type: integer
                  minimum: 0
                endRow:
                  type: integer
                  minimum: 1
                groupByAll:
                  type: boolean
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: string
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: string
                      last_page:
                        type: string
                        description: '''from'' => $this->firstItem(),'
                      per_page:
                        type: string
                      total:
                        type: string
                        description: '''to'' => $this->lastItem(),'
                    required:
                      - current_page
                      - last_page
                      - per_page
                      - total
                required:
                  - data
                  - meta
        '401':
          $ref: '#/components/responses/AuthenticationException'
        '422':
          $ref: '#/components/responses/ValidationException'
components:
  responses:
    AuthenticationException:
      description: Unauthenticated
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    ValidationException:
      description: Validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Errors overview.
              errors:
                type: object
                description: A detailed description of each field that failed validation.
                additionalProperties:
                  type: array
                  items:
                    type: string
            required:
              - message
              - errors
  securitySchemes:
    http:
      type: http
      scheme: bearer
      bearerFormat: JWT

````