---
title: "API_SetKeyField"
slug: "api-setkeyfield"
updated: 2025-08-18T09:35:44Z
published: 2025-08-18T09:35:44Z
---

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

# API_SetKeyField

**Don't forget to check out our**[**JSON RESTful APIs**](https://developer.quickbase.com/)**, they can help you utilize and extend Quickbase with ease.**

## Overview

Use API_SetKeyField to specify a field in the table as the key field. You invoke this call on a table dbid. You must have full administration rights on the application to use this call.

If you don't specify a key field, Quickbase uses the built-in Record ID field as the key field. However, if you want to use a different field as the key field for a table, the following conditions must be met:

- The field type you pick must support uniqueness (make sure the Unique checkbox is checked, which disallows duplicate entries).
- If there is data in the table, the field values must all be unique and cannot be blank.
- You cannot specify a List - user or Multi-select text field, or any formula field, as the key field in a table.

## Request parameters

| Parameter | Value | Required? |
| --- | --- | --- |
| ticket | A valid authentication ticket. The authentication ticket is returned via the API_Authenticate call. | yes, one of: - ticket - username/password - user token |
| usertoken | The user token is an alternative means of authentication, used for API access. User tokens cannot be used to access the Quickbase UI. | yes, one of: - ticket - username/password - user token |
| apptoken | A valid application token. | yes, if the application requires application tokens |
| fid | The field ID of the table field to be used as the key field. | yes |
| udata | A string value that you want returned. It will not be handled by Quickbase but it will be returned in the response. | no |

## Response values

| Element Name | Value |
| --- | --- |
| action | The originating request, for example, API_SetKeyField. |
| errcode | Identifies the error code, if any. (See the [Error Codes appendix](/v1/docs/error-codes) for a list of possible error codes.) 0 indicates that no error was encountered. |
| errtext | Text that explains the error code. "No error" indicates that no error was encountered. |
| udata | Optional. Contains any udata value supplied in the request. |

## Sample XML Request

```xml
POST https://target_domain/db/target_dbid?
Content-Type: application/xml
Content-Length:
QUICKBASE-ACTION: API_SetKeyField

<qdbapi>
   <ticket>auth_ticket</ticket>
   <apptoken>app_token</apptoken>
   <fid>6</fid>
   <udata>myudata</udata>
</qdbapi>
```

## URL alternative

```plaintext
https://target_domain/db/target_dbid?a=API_SetKeyField&fid=7
&ticket=auth_ticket&apptoken=app_token
```

where *target_domain* is the domain against which you are invoking this call, for example, *quickbase.com*. [Read about this notation](/v1/docs/understanding-the-api-call-reference).

## Sample response

```xml
<?xml version="1.0" ?>
<qdbapi>
   <action>API_SetKeyField</action>
   <errcode>0</errcode>
   <errtext>No error</errtext>
   <udata>myudata</udata>
</qdbapi>
```
