> ## 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.

# Create office

> Create a broker or advertiser office; the publisher generates office_id

## Overview

Create an office in the publisher system so ads can be attributed and billed correctly. You generate `office_id`. Targeter stores that id and sends it on later ad calls.

If an office with the same `name` already exists, return **200** with the existing office instead of creating a duplicate.

## Request

### Headers

* `Authorization: Bearer {token}` (required)
* `Content-Type: application/json`

### Body Parameters

<ParamField path="name" type="string" required>
  Office display name as used in Targeter (for example a brokerage office)
</ParamField>

### Example Request

```bash theme={null}
curl -X POST "https://publisher.example.com/v1/offices" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Torshov"
  }'
```

## Response

### Success (201 — new office)

<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"
}
```

### Success (200 — existing office)

Same body as **201** when `name` already exists.

## Error Responses

### 400 - Invalid request payload

```json theme={null}
{
    "error": "Invalid request payload",
    "details": [
        {
            "path": ["name"],
            "message": "Invalid input: expected string, received undefined"
        }
    ]
}
```

### 401 - Unauthorized

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

### 500 - Server Error

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


## OpenAPI

````yaml integrations/openapi.json POST /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:
    post:
      tags:
        - Offices
      summary: Create office
      description: >-
        Create an office in the publisher system. The publisher generates
        `office_id`. If an office with the same `name` already exists, return
        **200** with the existing office instead of creating a duplicate.
      operationId: createOffice
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOfficeRequest'
      responses:
        '200':
          description: Office already exists for the given name
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Office'
        '201':
          description: Office created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Office'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    CreateOfficeRequest:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          description: Office display name as used in Targeter
          example: Torshov
    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>`.

````