# Create A Report — LinkedIn Ads

> Queries the Analytics Finder to get analytics for the specified entity i.e company, account, campaign. See the docs here

- Key: `linkedin_ads-create-report`
- Type: Action (Read-only)
- Version: 0.0.8
- App: LinkedIn Ads (`linkedin_ads`) — https://pipedream.com/apps/linkedin-ads.md
- This page (HTML): https://pipedream.com/apps/linkedin-ads/actions/create-report
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/linkedin_ads/actions/create-report/create-report.mjs

## Description

Queries the Analytics Finder to get analytics for the specified entity i.e company, account, campaign. [See the docs here](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/ads-reporting/ads-reporting#analytics-finder)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `adAccountId` | `string` | Yes | Sponsored ad account id to match results by Options are loaded from the connected account. |
| `pivot` | `string` | Yes | Pivot of results, by which each report data point is grouped. The following enum values are supported: COMPANY - Group results by advertiser's company. ACCOUNT - Group results by account. SHARE - Group results by sponsored share. CAMPAIGN - Group results by campaign. CREATIVE - Group results by creative. CAMPAIGN_GROUP - Group results by campaign group. CONVERSION - Group results by conversion. CONVERSATION_NODE - The element row in the conversation will be the information for each individual node of the conversation tree. CONVERSATION_NODE_OPTION_INDEX - Used actionClicks are deaggregated and reported at the Node Button level. The second value of the pivot_values will be the index of the button in the node. SERVING_LOCATION - Group results by serving location, onsite or offsite. CARD_INDEX - Group results by the index of where a card appears in a carousel ad creative. Metrics are based on the index of the card at the time when the user's action (impression, click, etc.) happened on the creative (Carousel creatives only). MEMBER_COMPANY_SIZE - Group results by member company size. MEMBER_INDUSTRY - Group results by member industry. MEMBER_SENIORITY - Group results by member seniority. MEMBER_JOB_TITLE - Group results by member job title. MEMBER_JOB_FUNCTION - Group results by member job function. MEMBER_COUNTRY_V2 - Group results by member country. MEMBER_REGION_V2 - Group results by member region. MEMBER_COMPANY - Group results by member company. |
| `timeGranularity` | `string` | Yes | Time granularity of results. Valid enum values: ALL - Results grouped into a single result across the entire time range of the report. DAILY - Results grouped by day. MONTHLY - Results grouped by month. YEARLY - Results grouped by year. |
| `dateRangeStart` | `string` | Yes | Represents the inclusive start time range of the analytics. If unset, it indicates an open range up to the end time. Should be in the ISO 8601 format, e.g. 2022-12-27. |
| `dateRangeEnd` | `string` | No | Represents the inclusive end time range of the analytics. Must be after start time if it's present. If unset, it indicates an open range from start time to everything after. Should be in the ISO 8601 format, e.g. 2022-12-27. |
| `shares` | `string[]` | No | An Array of Share URN. Required unless another facet is provided. |
| `campaigns` | `string[]` | No | An Array of Sponsored Campaign URN. Required unless another facet is provided. |
| `creatives` | `string[]` | No | An Array of Sponsored Creative URN. Required unless another facet is provided. |
| `campaignGroups` | `string[]` | No | An Array of Campaign Group URN. Required unless another facet is provided. |
| `accounts` | `string[]` | No | An Array of Account URN. Required unless another facet is provided. Options are loaded from the connected account. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "linkedin_ads",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "linkedin_ads-create-report",
  arguments: {
    adAccountId: "Ad Account Id",
    pivot: "Pivot",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "linkedin_ads-create-report",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    linkedin_ads: { authProvisionId: "apn_xxxxxxx" },
    adAccountId: "Ad Account Id",
    pivot: "Pivot",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "linkedin_ads-create-report",
    "configured_props": {
      "linkedin_ads": { "authProvisionId": "apn_xxxxxxx" },
      "adAccountId": "Ad Account Id",
      "pivot": "Pivot"
    }
  }'
```

---

- App: https://pipedream.com/apps/linkedin-ads.md · All apps: https://pipedream.com/apps
