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

# Upsert one or multiple spend records

> Create or update daily spend records. Records are matched on platform and the campaign/adset/ad hierarchy plus date; existing records with the same key are overwritten. Batches of up to 1000 per call.



## OpenAPI

````yaml openapi/spend-v1.json POST /spend
openapi: 3.1.0
info:
  title: API - Spend - V1
  termsOfService: https://www.northbeam.io/terms
  version: 1.0.0
servers:
  - url: https://api.northbeam.io/v1
    description: Production Endpoint
  - url: https://api-uat.northbeam.io/v1
    description: >-
      User Acceptance Testing (UAT), Production Equivalent (provided for
      Customer Testing ONLY, spend submitted here does not get used in
      attribution)
security:
  - api_key: []
    client_id: []
tags: []
paths:
  /spend:
    post:
      summary: Upsert daily spend records
      description: >-
        Create or update daily spend records. Records are matched on platform
        and the campaign/adset/ad hierarchy plus date; existing records with the
        same key are overwritten. Batches of up to 1000 per call.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SpendUpsertInputPayload'
        required: true
      responses:
        '201':
          description: The spend records were successfully upserted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpendDefaultOutputPayload'
        '401':
          description: Authentication failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestError'
        '422':
          description: The request body is invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestError'
        4XX:
          description: An unexpected error occurred.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestError'
        5XX:
          description: An unexpected error occurred.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestError'
      deprecated: false
components:
  schemas:
    SpendUpsertInputPayload:
      properties:
        data:
          items:
            $ref: '#/components/schemas/SpendUpsertInput'
          type: array
          title: Data
      type: object
      required:
        - data
      title: Spend Entries
    SpendDefaultOutputPayload:
      properties:
        data:
          items:
            $ref: '#/components/schemas/SpendDefaultOutput'
          type: array
          title: Data
      type: object
      required:
        - data
      title: Spend Entries Return
    RequestError:
      properties:
        errors:
          anyOf:
            - items:
                $ref: '#/components/schemas/ErrorLoc'
              type: array
            - type: 'null'
          title: Errors
        message:
          type: string
          title: Message
        request_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Request Id
      type: object
      required:
        - message
      title: RequestError
    SpendUpsertInput:
      properties:
        date:
          type: string
          format: date
          title: Date
          description: The date of spend entry to upsert, required
          examples:
            - '1970-01-01'
        platform_account_id:
          type: string
          title: Platform Account Id
          description: >-
            The Ad Platform Account ID to upsert, used for segregating ad
            objects per ad platform account
          default: ''
          examples:
            - '12345'
        platform_name:
          type: string
          title: Platform Name
          description: The Ad Platform Name to upsert, required
          examples:
            - Facebook
        campaign_id:
          type: string
          title: Campaign Id
          description: >-
            The Ad Platform's Campaign ID (utm_campaign, if known) to upsert,
            required
          examples:
            - '12345'
        campaign_name:
          type: string
          title: Campaign Name
          description: >-
            The Ad Platform Campaign Name to upsert - will be as Ad Name in the
            Northbeam Dashboard - can be the same as `campaign_id`
          examples:
            - Banana Festival Awareness Campaign
        adset_id:
          type: string
          title: Adset Id
          description: >-
            The Ad Platform's Adset ID (utm_term, if known) to upsert, defaults
            to '' if empty (not all platforms support adsets)
          default: ''
          examples:
            - '12345'
        adset_name:
          type: string
          title: Adset Name
          description: >-
            The Ad Platform Adset Name to upsert - will be as Ad Name in the
            Northbeam Dashboard - can be the same as `adset_id` - defaults to ''
            if empty
          default: ''
          examples:
            - Banana Adset
        ad_id:
          type: string
          title: Ad Id
          description: >-
            The Ad Platform's Ad ID (utm_content, if known) to upsert, defaults
            to '' if empty (not all platforms support ads)
          default: ''
          examples:
            - '12345'
        ad_name:
          type: string
          title: Ad Name
          description: >-
            The Ad Platform Ad Name to upsert - will be as Ad Name in the
            Northbeam Dashboard - can be the same as `adset_id` - defaults to ''
            if empty
          default: ''
          examples:
            - Banana Ad
        spend:
          type: number
          minimum: 0
          title: Spend
          description: >-
            Amount (in currency) spent on ad object to upsert, defaults to 0 if
            empty
          examples:
            - '123'
        spend_currency:
          type: string
          maxLength: 3
          minLength: 3
          title: Spend Currency
          description: The Currency of the Spend per ISO 4217 to upsert, required
          examples:
            - USD
            - CAD
        impressions:
          type: number
          minimum: 0
          title: Impressions
          description: >-
            The amount of impressions the ad object received on a given date,
            defaults to 0 if empty
          default: 0
          examples:
            - 299
        clicks:
          type: number
          minimum: 0
          title: Clicks
          description: >-
            The amount of clicks the ad object received on a given date,
            defaults to 0 if empty
          default: 0
          examples:
            - 0
      type: object
      required:
        - date
        - platform_name
        - campaign_id
        - campaign_name
        - spend
        - spend_currency
      title: Spend Entry
    SpendDefaultOutput:
      properties:
        date:
          type: string
          format: date
          title: Date
          description: The date of spend entry to upsert, required
          examples:
            - '1970-01-01'
        platform_account_id:
          type: string
          title: Platform Account Id
          description: >-
            The Ad Platform Account ID to upsert, used for segregating ad
            objects per ad platform account
          default: ''
          examples:
            - '12345'
        platform_name:
          type: string
          title: Platform Name
          description: The Ad Platform Name to upsert, required
          examples:
            - Facebook
        campaign_id:
          type: string
          title: Campaign Id
          description: >-
            The Ad Platform's Campaign ID (utm_campaign, if known) to upsert,
            required
          examples:
            - '12345'
        campaign_name:
          type: string
          title: Campaign Name
          description: >-
            The Ad Platform Campaign Name to upsert - will be as Ad Name in the
            Northbeam Dashboard - can be the same as `campaign_id`
          examples:
            - Banana Festival Awareness Campaign
        adset_id:
          type: string
          title: Adset Id
          description: >-
            The Ad Platform's Adset ID (utm_term, if known) to upsert, defaults
            to '' if empty (not all platforms support adsets)
          default: ''
          examples:
            - '12345'
        adset_name:
          type: string
          title: Adset Name
          description: >-
            The Ad Platform Adset Name to upsert - will be as Ad Name in the
            Northbeam Dashboard - can be the same as `adset_id` - defaults to ''
            if empty
          default: ''
          examples:
            - Banana Adset
        ad_id:
          type: string
          title: Ad Id
          description: >-
            The Ad Platform's Ad ID (utm_content, if known) to upsert, defaults
            to '' if empty (not all platforms support ads)
          default: ''
          examples:
            - '12345'
        ad_name:
          type: string
          title: Ad Name
          description: >-
            The Ad Platform Ad Name to upsert - will be as Ad Name in the
            Northbeam Dashboard - can be the same as `adset_id` - defaults to ''
            if empty
          default: ''
          examples:
            - Banana Ad
        spend:
          type: number
          minimum: 0
          title: Spend
          description: >-
            Amount (in currency) spent on ad object to upsert, defaults to 0 if
            empty
          examples:
            - '123'
        spend_currency:
          type: string
          maxLength: 3
          minLength: 3
          title: Spend Currency
          description: The Currency of the Spend per ISO 4217 to upsert, required
          examples:
            - USD
            - CAD
        impressions:
          type: number
          minimum: 0
          title: Impressions
          description: >-
            The amount of impressions the ad object received on a given date,
            defaults to 0 if empty
          default: 0
          examples:
            - 299
        clicks:
          type: number
          minimum: 0
          title: Clicks
          description: >-
            The amount of clicks the ad object received on a given date,
            defaults to 0 if empty
          default: 0
          examples:
            - 0
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
        - date
        - platform_name
        - campaign_id
        - campaign_name
        - spend
        - spend_currency
        - created_at
        - updated_at
      title: Spend Entry Return
    ErrorLoc:
      properties:
        loc:
          type: string
          title: Loc
        msg:
          type: string
          title: Msg
        type:
          type: string
          title: Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ErrorLoc
  securitySchemes:
    api_key:
      type: apiKey
      name: Authorization
      in: header
    client_id:
      type: apiKey
      name: Data-Client-ID
      in: header

````