> This page is for Unified.

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

# /field-mappings/{field_mapping_id}

PATCH https://api.merge.dev/api/filestorage/v1/field-mappings/{field_mapping_id}
Content-Type: application/json

Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync **ALL** data from start.

Reference: https://docs.merge.dev/merge-unified/filestorage/linked-account/field-mapping/field-mappings-destroy

## Authentication

- `Authorization` header (bearer token, required) — Token-based authentication with required prefix "Bearer"

## Servers

- `https://api.merge.dev/api` (Production, default)
- `https://api-eu.merge.dev/api` (ProductionEU)
- `https://api-ap.merge.dev/api` (ProductionAPSE1)

## Request

### Path parameters

- `field_mapping_id` (string, required)

### Query parameters

- `remote_data_iteration_count` (integer, optional) — Number of common model instances to iterate through when fetching remote data for field mappings. Defaults to 250 if not provided.

### Headers

- `X-Account-Token` (string, required) — Token identifying the end user.

### Body (application/json)

This endpoint expects a PatchedEditFieldMappingRequest.

- `remote_field_traversal_path` (list of any, optional) — The field traversal path of the remote field listed when you hit the GET /remote-fields endpoint.
- `remote_method` (string, optional) — The method of the remote endpoint where the remote field is coming from.
- `remote_url_path` (string, optional) — The path of the remote endpoint where the remote field is coming from.
- `jmes_path` (string, optional) — DEPRECATED: Use 'advanced_mapping_expression' instead.
- `advanced_mapping_expression` (string, optional) — A JSONata expression used to transform the remote field data.

## Response

### 200

- `model` (FieldMappingApiInstance, required)
- `warnings` (list of WarningValidationProblem, required)
- `errors` (list of ErrorValidationProblem, required)
- `logs` (list of DebugModeLog, optional)

## Types

### FieldMappingApiInstance

- `id` (string, optional)
- `is_integration_wide` (boolean, optional)
- `target_field` (FieldMappingApiInstanceTargetField, optional, nullable)
- `remote_field` (FieldMappingApiInstanceRemoteField, optional, nullable)
- `jmes_path` (string, optional, nullable)
- `advanced_mapping_expression` (string, optional, nullable)

### WarningValidationProblem

- `title` (string, required)
- `detail` (string, required)
- `problem_type` (string, required)
- `source` (ValidationProblemSource, optional)
- `block_merge_link` (boolean, optional)
- `raw_error` (string, optional)
- `error_code` (integer, optional)

### ErrorValidationProblem

- `title` (string, required)
- `detail` (string, required)
- `problem_type` (string, required)
- `source` (ValidationProblemSource, optional)
- `block_merge_link` (boolean, optional)
- `raw_error` (string, optional)
- `error_code` (integer, optional)

### DebugModeLog

- `log_id` (string, required)
- `dashboard_view` (string, required)
- `log_summary` (DebugModelLogSummary, required)

### FieldMappingApiInstanceTargetField

- `name` (string, required)
- `description` (string, required)
- `is_organization_wide` (boolean, required)

### FieldMappingApiInstanceRemoteField

- `remote_key_name` (string, required, nullable)
- `schema` (map from string to any, required, nullable)
- `remote_endpoint_info` (FieldMappingApiInstanceRemoteFieldRemoteEndpointInfo, required)

### ValidationProblemSource

- `pointer` (string, required)

### DebugModelLogSummary

- `url` (string, required)
- `method` (string, required)
- `status_code` (integer, required)

### FieldMappingApiInstanceRemoteFieldRemoteEndpointInfo

- `method` (string, required, nullable)
- `url_path` (string, required, nullable)
- `field_traversal_path` (list of string, required, nullable)

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "model": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "is_integration_wide": true,
    "target_field": {
      "name": "example_target_field_name",
      "description": "this is a example description of a target field",
      "is_organization_wide": true
    },
    "remote_field": {
      "remote_key_name": "example_remote_field_key",
      "schema": {
        "type": "string"
      },
      "remote_endpoint_info": {
        "method": "GET",
        "url_path": "/example-url-path",
        "field_traversal_path": [
          "example_remote_field_key"
        ]
      }
    },
    "jmes_path": "[0].example_jmes_path",
    "advanced_mapping_expression": "$[0].example_jsonata"
  },
  "warnings": [
    {
      "title": "Unrecognized Field",
      "detail": "An unrecognized field, age, was passed in with request data.",
      "problem_type": "UNRECOGNIZED_FIELD",
      "source": {
        "pointer": "/age"
      },
      "block_merge_link": true,
      "raw_error": "string",
      "error_code": 1
    }
  ],
  "errors": [
    {
      "title": "Missing Required Field",
      "detail": "custom_fields is a required field on model.",
      "problem_type": "MISSING_REQUIRED_FIELD",
      "source": {
        "pointer": "/model/custom_fields"
      },
      "block_merge_link": true,
      "raw_error": "string",
      "error_code": 1
    }
  ],
  "logs": [
    {
      "log_id": "99433219-8017-4acd-bb3c-ceb23d663832",
      "dashboard_view": "https://app.merge.dev/logs/99433219-8017-4acd-bb3c-ceb23d663832",
      "log_summary": {
        "url": "www.exampleintegration.com/api/v1/exampleapi",
        "method": "POST",
        "status_code": 200
      }
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.merge.dev/api/filestorage/v1/field-mappings/field_mapping_id"

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

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

print(response.json())
```

```javascript
const url = 'https://api.merge.dev/api/filestorage/v1/field-mappings/field_mapping_id';
const options = {
  method: 'PATCH',
  headers: {
    'X-Account-Token': 'X-Account-Token',
    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.merge.dev/api/filestorage/v1/field-mappings/field_mapping_id"

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

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

	req.Header.Add("X-Account-Token", "X-Account-Token")
	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.merge.dev/api/filestorage/v1/field-mappings/field_mapping_id")

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

request = Net::HTTP::Patch.new(url)
request["X-Account-Token"] = 'X-Account-Token'
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.merge.dev/api/filestorage/v1/field-mappings/field_mapping_id")
  .header("X-Account-Token", "X-Account-Token")
  .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.merge.dev/api/filestorage/v1/field-mappings/field_mapping_id', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'X-Account-Token' => 'X-Account-Token',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.merge.dev/api/filestorage/v1/field-mappings/field_mapping_id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("X-Account-Token", "X-Account-Token");
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 = [
  "X-Account-Token": "X-Account-Token",
  "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.merge.dev/api/filestorage/v1/field-mappings/field_mapping_id")! 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()
```