> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.beehiiv.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.beehiiv.com/_mcp/server.

# Assign publication field values <Badge intent="info" minimal outlined>OAuth Scope: publication_fields:write</Badge>

PATCH https://api.beehiiv.com/v2/workspaces/publication_fields/{publicationFieldId}/values
Content-Type: application/json

This feature is currently in beta and the API is subject to change.

Assign one publication field's value across many publications at once. Each key in `values` is a publication ID and each value is what that publication should resolve to. Sending `null` or an empty string removes the publication's own value, leaving it to resolve to the field's default value again. Rows are written independently, so one rejected publication does not cost the rest of the batch. When any row is rejected the response is `207` and `errors` names the publications that were not written. A request that fails outright writes nothing at all. Up to 2000 publications may be sent in a single request. Archived fields accept values, since their values still resolve in content. Fetched fields do not, since their values come from the configured endpoint. Requires an API key with access to every publication in the workspace.

Reference: https://developers.beehiiv.com/api-reference/publication-fields/values-update

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `publicationFieldId` (string, required) — The prefixed ID of the publication field object

### Body (application/json)

This endpoint expects an object.

- `values` (map from string to string, required) — The value each publication should resolve to, keyed by prefixed publication ID. A null or empty value clears the publication's own value.

## Response

### 200

OK

- `data` (PublicationFieldValuesAssignResult, required)

## Errors

### 207 Publication Field Values Partial Success Error

Some rows were written and others were rejected. The body is the same as a successful response; `errors` names every publication that was not written.

- `data` (PublicationFieldValuesAssignResult, required)

### 400 Bad Request Error

Bad Request

- `status` (integer, required)
- `statusText` (string, required)
- `errors` (list of ErrorDetail, required)

### 401 Unauthorized Error

Unauthorized. The API key or OAuth access token is missing, invalid, or expired.

- `status` (integer, required)
- `statusText` (string, required)
- `errors` (list of ErrorDetail, required)

### 403 Forbidden Error

Forbidden

- `status` (integer, required)
- `statusText` (string, required)
- `errors` (list of ErrorDetail, required)

### 404 Not Found Error

Resource Not Found

- `status` (integer, required)
- `statusText` (string, required)
- `errors` (list of ErrorDetail, required)

### 422 Unprocessable Entity Error

Unprocessable Entity

- `status` (integer, required)
- `statusText` (string, required)
- `errors` (list of ErrorDetail, required)

### 429 Too Many Requests Error

Rate Limit Exceeded

- `status` (integer, required)
- `statusText` (string, required)
- `errors` (list of ErrorDetail, required)

### 500 Internal Server Error

Internal Server Error

- `status` (integer, required)
- `statusText` (string, required)
- `errors` (list of ErrorDetail, required)

## Types

### PublicationFieldValuesAssignResult

- `assigned` (integer, required) — The number of publications given a new value. Rows resubmitting the value a publication already holds are not counted.
- `cleared` (integer, required) — The number of publications whose own value was removed, leaving them to resolve to the field's default value again.
- `errors` (list of PublicationFieldValueAssignError, required) — The rows that were rejected. Empty when every row was written.

### ErrorDetail

- `message` (string, required)
- `code` (string, required)

### PublicationFieldValueAssignError

- `publication_id` (string, required) — The publication the row named, echoed exactly as it was submitted.
- `errors` (list of string, required) — Why the row was rejected.

## Examples

### Example 1

**Request**

```json
{
  "values": {
    "pub_00000000-0000-0000-0000-000000000000": "help@morningbrew.com",
    "pub_22222222-2222-2222-2222-222222222222": null
  }
}
```

**Response**

```json
{
  "data": {
    "assigned": 1,
    "cleared": 1,
    "errors": []
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.beehiiv.com/v2/workspaces/publication_fields/pub_field_00000000-0000-0000-0000-000000000000/values"

payload = { "values": {
        "pub_00000000-0000-0000-0000-000000000000": "help@morningbrew.com",
        "pub_22222222-2222-2222-2222-222222222222": None
    } }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.beehiiv.com/v2/workspaces/publication_fields/pub_field_00000000-0000-0000-0000-000000000000/values';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"values":{"pub_00000000-0000-0000-0000-000000000000":"help@morningbrew.com","pub_22222222-2222-2222-2222-222222222222":null}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.beehiiv.com/v2/workspaces/publication_fields/pub_field_00000000-0000-0000-0000-000000000000/values"

	payload := strings.NewReader("{\n  \"values\": {\n    \"pub_00000000-0000-0000-0000-000000000000\": \"help@morningbrew.com\",\n    \"pub_22222222-2222-2222-2222-222222222222\": null\n  }\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.beehiiv.com/v2/workspaces/publication_fields/pub_field_00000000-0000-0000-0000-000000000000/values")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"values\": {\n    \"pub_00000000-0000-0000-0000-000000000000\": \"help@morningbrew.com\",\n    \"pub_22222222-2222-2222-2222-222222222222\": null\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.beehiiv.com/v2/workspaces/publication_fields/pub_field_00000000-0000-0000-0000-000000000000/values")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"values\": {\n    \"pub_00000000-0000-0000-0000-000000000000\": \"help@morningbrew.com\",\n    \"pub_22222222-2222-2222-2222-222222222222\": null\n  }\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.beehiiv.com/v2/workspaces/publication_fields/pub_field_00000000-0000-0000-0000-000000000000/values', [
  'body' => '{
  "values": {
    "pub_00000000-0000-0000-0000-000000000000": "help@morningbrew.com",
    "pub_22222222-2222-2222-2222-222222222222": null
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.beehiiv.com/v2/workspaces/publication_fields/pub_field_00000000-0000-0000-0000-000000000000/values");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"values\": {\n    \"pub_00000000-0000-0000-0000-000000000000\": \"help@morningbrew.com\",\n    \"pub_22222222-2222-2222-2222-222222222222\": null\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["values": [
    "pub_00000000-0000-0000-0000-000000000000": "help@morningbrew.com",
    "pub_22222222-2222-2222-2222-222222222222": 
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beehiiv.com/v2/workspaces/publication_fields/pub_field_00000000-0000-0000-0000-000000000000/values")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Example 2

**Request**

```json
{}
```

**Response**

```json
{
  "data": {
    "assigned": 0,
    "cleared": 0,
    "errors": [
      {
        "publication_id": "string",
        "errors": [
          "string"
        ]
      }
    ]
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.beehiiv.com/v2/workspaces/publication_fields/%3ApublicationFieldId/values"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.beehiiv.com/v2/workspaces/publication_fields/%3ApublicationFieldId/values';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.beehiiv.com/v2/workspaces/publication_fields/%3ApublicationFieldId/values"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.beehiiv.com/v2/workspaces/publication_fields/%3ApublicationFieldId/values")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.beehiiv.com/v2/workspaces/publication_fields/%3ApublicationFieldId/values")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.beehiiv.com/v2/workspaces/publication_fields/%3ApublicationFieldId/values', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.beehiiv.com/v2/workspaces/publication_fields/%3ApublicationFieldId/values");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beehiiv.com/v2/workspaces/publication_fields/%3ApublicationFieldId/values")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```