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

# Get office ID

> Resolve an office in the publisher system and return its generated office_id

## Overview

Look up an office by `name` and/or `id` and return the publisher-generated `office_id`. Targeter uses this before [creating an ad](/integrations/ads/create). If the office does not exist, Targeter may [create it](/integrations/offices/create).

Provide at least one query parameter.

## Request

### Headers

* `Authorization: Bearer {token}` (required)

### Query Parameters

<ParamField query="name" type="string">
  Office display name as known in Targeter
</ParamField>

<ParamField query="id" type="string">
  Publisher-generated office id, if already known
</ParamField>

### Example Request

```bash theme={null}
curl "https://publisher.example.com/v1/offices?name=Torshov" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

## Response

### Success (200)

<ResponseField name="office_id" type="string">
  Publisher-generated office id
</ResponseField>

<ResponseField name="name" type="string">
  Office display name
</ResponseField>

```json theme={null}
{
    "office_id": "off_8k2mQx",
    "name": "Torshov"
}
```

## Error Responses

### 400 - Invalid request payload

Neither `name` nor `id` was provided.

```json theme={null}
{
    "error": "Provide name or id"
}
```

### 401 - Unauthorized

```json theme={null}
{
    "error": "Missing or invalid Authorization header"
}
```

### 404 - Office not found

```json theme={null}
{
    "error": "Office not found"
}
```

### 500 - Server Error

```json theme={null}
{
    "error": "Unexpected server error. Please try again later."
}
```


## OpenAPI

````yaml integrations/openapi.json GET /offices
openapi: 3.1.0
info:
  title: Targeter Ideal Publisher API
  description: >-
    Contract Targeter expects from publisher and media platforms it creates ads
    on and fetches insights from. Implement these endpoints so Targeter can
    manage offices, ads, and reporting against your system.
  version: 1.0.0
  contact:
    name: Targeter Integration Support
servers:
  - url: https://{publisher_host}/v1
    description: Publisher API host (provided during integration setup)
    variables:
      publisher_host:
        default: publisher.example.com
security:
  - BearerAuth: []
tags:
  - name: Offices
    description: Broker or advertiser offices that ads are billed and attributed to
  - name: Ads
    description: Create, update, pause, resume, and delete ads
  - name: Insights
    description: Performance reporting for ads Targeter has created
  - name: Platforms
    description: Publisher channels available for delivery
paths:
  /offices:
    get:
      tags:
        - Offices
      summary: Get office ID
      description: >-
        Resolve an office in the publisher system and return its generated
        `office_id`. Look up by `name` and/or publisher `id`.
      operationId: getOffice
      parameters:
        - name: name
          in: query
          required: false
          description: Office display name as known in Targeter
          schema:
            type: string
          example: Torshov
        - name: id
          in: query
          required: false
          description: Publisher-generated office id, if already known
          schema:
            type: string
          example: off_8k2mQx
      responses:
        '200':
          description: Office found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Office'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Office not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Office not found
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    Office:
      type: object
      required:
        - office_id
        - name
      properties:
        office_id:
          type: string
          description: Publisher-generated office id
          example: off_8k2mQx
        name:
          type: string
          description: Office display name
          example: Torshov
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Error message
          example: Missing required field
        details:
          type: array
          description: Per-field validation issues
          items:
            type: object
            required:
              - message
            properties:
              path:
                type: array
                items:
                  type: string
                example:
                  - material
                  - target_url
              message:
                type: string
                example: Target URL is required
  responses:
    BadRequest:
      description: Invalid request payload
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Invalid request payload
            details:
              - path:
                  - name
                message: 'Invalid input: expected string, received undefined'
    Unauthorized:
      description: Missing Authorization header, or invalid or expired token
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            missingHeader:
              value:
                error: Missing or invalid Authorization header
            invalidToken:
              value:
                error: Invalid or expired token
    ServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Unexpected server error. Please try again later.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        API token issued to Targeter during integration setup. Send as
        `Authorization: Bearer <token>`.

````