---
title: List Custom Fields for a project
slug: feature-experimentation/api/list-custom-fields-for-a-project
docTags: 
createdAt: 2026-08-28T15:54:06.731Z
---

{
  "id": "4rWcIJ94FQCIWJXyJPNfT",
  "type": "api-oas-v2",
  "data": {
    "method": "GET",
    "url": "https://api.optimizely.com/flags/v1//projects/{project_id}/custom_fields",
    "servers": [
      {
        "url": "https://api.optimizely.com/flags/v1//projects/{project_id}/custom_fields"
      }
    ],
    "name": "List Custom Fields for a project",
    "description": "Get a list of Custom Fields within a Project.",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "project_id",
          "type": "integer",
          "example": 12345,
          "description": "The project identifier"
        }
      ],
      "headerParameters": [],
      "queryParameters": [
        {
          "kind": "optional",
          "name": "per_page",
          "type": "integer<int64>",
          "description": "The max number of items to include per page or results.",
          "format": "int64"
        },
        {
          "kind": "optional",
          "name": "page_token",
          "type": "string",
          "description": "<p>Pagination page token. Implements prev, next, last, first</p>"
        },
        {
          "kind": "optional",
          "name": "page_window",
          "type": "integer",
          "description": "<p>Number of previous and next page links to supply for the request (defaults to 1).</p>"
        },
        {
          "kind": "optional",
          "name": "query",
          "type": "string",
          "description": "<p>Substring search across <code>key</code>, <code>name</code> and <code>description</code> (case-insensitive).</p>"
        },
        {
          "kind": "optional",
          "name": "sort",
          "type": "array",
          "description": "Sort the custom fields based on the attributes from left to right.\n",
          "schema": [],
          "itemType": "string",
          "customType": "string[]"
        },
        {
          "kind": "optional",
          "name": "archived",
          "type": "boolean",
          "description": "<p>Filter the custom fields by archived. A custom field can be either archived (archived=true) or unarchived (archived=false)</p>"
        },
        {
          "kind": "optional",
          "name": "key",
          "type": "string",
          "description": "Filter the custom fields by key.\n"
        },
        {
          "kind": "optional",
          "name": "entity_type",
          "type": "string",
          "description": "Filter the custom fields by entity type.\n",
          "enum": [
            "flag",
            "rule"
          ]
        },
        {
          "kind": "optional",
          "name": "field_type",
          "type": "string",
          "description": "Filter the custom fields by field type.\n",
          "enum": [
            "text",
            "number",
            "boolean",
            "link",
            "label"
          ]
        }
      ],
      "bodyDataParameters": [],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "apiKey",
          "name": "apiKey",
          "kind": "optional",
          "type": "http",
          "scheme": "bearer"
        },
        {
          "id": "OAuth2",
          "name": "OAuth2",
          "kind": "optional",
          "type": "oauth2",
          "description": "Write applications that authenticate with the REST API via OAuth 2.0.",
          "oauth2Flows": {
            "authorizationCode": {
              "authorizationUrl": "https://app.optimizely.com/oauth2/authorize",
              "tokenUrl": "https://app.optimizely.com/oauth2/token",
              "scopes": {
                "all": "Grants all access"
              }
            }
          },
          "requiredScopes": [
            "read",
            "write"
          ]
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "<p>Successful retrieval of a list of custom fields.</p>\n<p>The response includes RESTful JSON (<a href=\"https://restfuljson.org/\" target=\"_blank\">https://restfuljson.org/</a>) styled links. If a\nlink is not present in the response, it indicates a user is not authorized to access\nthe related resource.</p>",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "CustomFieldsList",
            "schema": [
              {
                "name": "count",
                "kind": "required",
                "type": "integer",
                "description": "Number of CustomFields on the current page.",
                "example": 2
              },
              {
                "name": "first_url",
                "kind": "required",
                "type": "object",
                "description": "Link to first page of CustomFields in a series.",
                "complexType": "allOf",
                "complexItems": [
                  {
                    "name": "UrlValue",
                    "description": "",
                    "modelRef": "#/components/schemas/UrlValue",
                    "schema": []
                  }
                ],
                "schema": []
              },
              {
                "name": "items",
                "kind": "required",
                "type": "array",
                "description": "Represents custom fields for entities\n",
                "modelRef": "#/components/schemas/CustomField",
                "customType": "CustomField[]",
                "schema": [
                  {
                    "name": "archived",
                    "kind": "optional",
                    "type": "boolean",
                    "description": "Whether the custom field is archived. New custom fields are created as unarchived by default.",
                    "example": false
                  },
                  {
                    "name": "created_by_user_id",
                    "kind": "optional",
                    "type": "string",
                    "readOnly": true,
                    "nullable": true,
                    "description": "<p>Identifier of the user who created this custom field (often an email).</p>",
                    "example": "user@company.com"
                  },
                  {
                    "name": "created_time",
                    "kind": "optional",
                    "type": "string<date-time>",
                    "readOnly": true,
                    "nullable": true,
                    "description": "Timestamp when the custom field was created.",
                    "example": "2024-01-01T10:00:00.000Z",
                    "format": "date-time"
                  },
                  {
                    "name": "default_value",
                    "kind": "optional",
                    "type": "string",
                    "description": "Default value for the custom field if applicable.",
                    "example": "option1"
                  },
                  {
                    "name": "description",
                    "kind": "optional",
                    "type": "string",
                    "description": "Optional detailed description explaining the purpose and context of this CustomField.\nHelps team members understand what this CustomField is measuring.\n",
                    "example": "Custom field to tag experiments owned by the analytics team",
                    "maxLength": 1000
                  },
                  {
                    "name": "entity_type",
                    "kind": "required",
                    "type": "string<flag | rule>",
                    "description": "Type of entity the custom field is associated with",
                    "example": "flag",
                    "enum": [
                      "flag",
                      "rule"
                    ]
                  },
                  {
                    "name": "field_type",
                    "kind": "required",
                    "type": "string<text | number | boolean | link | label>",
                    "description": "<p>The type of the custom field (e.g., text, number, boolean, link, label)</p>",
                    "example": "text",
                    "enum": [
                      "text",
                      "number",
                      "boolean",
                      "link",
                      "label"
                    ]
                  },
                  {
                    "name": "id",
                    "kind": "required",
                    "type": "integer",
                    "readOnly": true,
                    "description": "<p>System-generated unique identifier for the CustomField.</p>",
                    "example": 12345
                  },
                  {
                    "name": "key",
                    "kind": "required",
                    "type": "string",
                    "description": "<p>Unique user-defined identifier for the CustomField within the project.\nMust contain only alphanumeric characters, underscores, and hyphens.</p>",
                    "example": "analytics_team",
                    "maxLength": 64,
                    "pattern": "^[a-zA-Z0-9_\\-]+$"
                  },
                  {
                    "name": "name",
                    "kind": "required",
                    "type": "string",
                    "description": "<p>Human-readable name for the CustomField displayed in the UI.</p>",
                    "example": "Analytics Team",
                    "maxLength": 255
                  },
                  {
                    "name": "project_id",
                    "kind": "optional",
                    "type": "integer<int64>",
                    "readOnly": true,
                    "description": "The unique identifier of the project this CustomField belongs to.",
                    "example": 98765,
                    "format": "int64"
                  },
                  {
                    "name": "required",
                    "kind": "required",
                    "type": "boolean",
                    "description": "Indicates if the custom field is required for the associated entity.",
                    "example": false
                  },
                  {
                    "name": "updated_time",
                    "kind": "optional",
                    "type": "string<date-time>",
                    "readOnly": true,
                    "description": "Timestamp when the custom field was last updated.",
                    "example": "2024-01-01T10:00:00.000Z",
                    "format": "date-time"
                  },
                  {
                    "name": "validation",
                    "kind": "optional",
                    "type": "object",
                    "nullable": true,
                    "description": "<p>Validation rules for the custom field if applicable.\nAllowed keys depend on field_type:</p>\n<ul>\n<li>text → max_length, regex</li>\n<li>number → min, max, decimal_places, use_thousand_separator</li>\n<li>label → field_options, allow_multi_select</li>\n<li>link → no validation fields</li>\n<li>boolean → no validation fields</li>\n</ul>",
                    "example": "{\"max\":100,\"max_length\":255,\"min\":1}",
                    "schema": [
                      {
                        "name": "allow_multi_select",
                        "kind": "optional",
                        "type": "boolean",
                        "description": "Whether multiple values can be selected for label fields.",
                        "example": false
                      },
                      {
                        "name": "decimal_places",
                        "kind": "optional",
                        "type": "integer",
                        "description": "Number of allowed decimal places for numeric values.",
                        "example": 2
                      },
                      {
                        "name": "field_options",
                        "kind": "optional",
                        "type": "array",
                        "description": "Allowed values for label fields.",
                        "example": "[\"US\",\"EU\",\"APAC\"]",
                        "itemType": "string",
                        "customType": "string[]",
                        "itemExample": "",
                        "itemDefault": ""
                      },
                      {
                        "name": "max",
                        "kind": "optional",
                        "type": "number",
                        "description": "Maximum value for number fields.",
                        "example": 100
                      },
                      {
                        "name": "max_length",
                        "kind": "optional",
                        "type": "integer",
                        "description": "Maximum length for string fields.",
                        "example": 255
                      },
                      {
                        "name": "min",
                        "kind": "optional",
                        "type": "number",
                        "description": "Minimum value for number fields.",
                        "example": 1
                      },
                      {
                        "name": "regex",
                        "kind": "optional",
                        "type": "string",
                        "description": "Regular expression that the input must match.",
                        "example": "^[A-Za-z0-9_-]+$"
                      },
                      {
                        "name": "use_thousand_separator",
                        "kind": "optional",
                        "type": "boolean",
                        "description": "<p>Whether thousand separators should be permitted/displayed.</p>",
                        "example": true
                      }
                    ]
                  }
                ]
              },
              {
                "name": "last_url",
                "kind": "required",
                "type": "object",
                "description": "Link to the last page of CustomFields in a series.",
                "complexType": "allOf",
                "complexItems": [
                  {
                    "name": "UrlValue",
                    "description": "",
                    "modelRef": "#/components/schemas/UrlValue",
                    "schema": []
                  }
                ],
                "schema": []
              },
              {
                "name": "next_url",
                "kind": "optional",
                "type": "object",
                "description": "<p>List of links to next pages of CustomFields in a series.</p>\n<p>The first element in the array is the exact next page after the current record, etc.</p>",
                "complexType": "allOf",
                "complexItems": [
                  {
                    "name": "UrlList",
                    "description": "",
                    "modelRef": "#/components/schemas/UrlList",
                    "schema": []
                  }
                ],
                "schema": []
              },
              {
                "name": "page",
                "kind": "required",
                "type": "integer",
                "description": "<p>Number of the current page. 1-index based.</p>",
                "example": 5
              },
              {
                "name": "prev_url",
                "kind": "optional",
                "type": "object",
                "description": "<p>List of links to previous pages of CustomFields in a series.</p>\n<p>The first element in the array is the exact previous page before the current record, etc.</p>",
                "complexType": "allOf",
                "complexItems": [
                  {
                    "name": "UrlList",
                    "description": "",
                    "modelRef": "#/components/schemas/UrlList",
                    "schema": []
                  }
                ],
                "schema": []
              },
              {
                "name": "total_count",
                "kind": "required",
                "type": "integer",
                "description": "Total number of CustomFields for this series.",
                "example": 20
              },
              {
                "name": "total_pages",
                "kind": "required",
                "type": "integer",
                "description": "Total number of pages for this series.",
                "example": 10
              },
              {
                "name": "url",
                "kind": "required",
                "type": "object",
                "description": "Link to self",
                "complexType": "allOf",
                "complexItems": [
                  {
                    "name": "UrlValue",
                    "description": "",
                    "modelRef": "#/components/schemas/UrlValue",
                    "schema": []
                  }
                ],
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/CustomFieldsList",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "Malformed requests and invalid parameter names and types",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "401",
        "description": "Invalid credentials",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "403",
        "description": "Do not have permission to perform the operation",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "404",
        "description": "Not found. No content",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "BQgWpGzAfD1U5-P4LzV3S",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request GET \\\n     --url https://api.optimizely.com/flags/v1//projects/{project_id}/custom_fields \\\n     --header 'accept: application/json'"
        },
        {
          "id": "aSEsWSmlzqHk3rEPNsA-L",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar requestOptions = {\n   method: 'GET',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.optimizely.com/flags/v1//projects/{project_id}/custom_fields\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "arh2D9YvT4_iI5VI-dlqM",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.optimizely.com/flags/v1//projects/{project_id}/custom_fields\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Get.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "4bNYAJq-uJ5AJ3KRubkSF",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.optimizely.com/flags/v1//projects/{project_id}/custom_fields\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"GET\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "BQgWpGzAfD1U5-P4LzV3S"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// Successful retrieval of a list of custom fields.\nThe response includes RESTful JSON (https://restfuljson.org/) styled links. If a\nlink is not present in the response, it indicates a user is not authorized to access\nthe related resource.\n{\n  \"count\": 2,\n  \"first_url\": {},\n  \"items\": [\n    {\n      \"archived\": false,\n      \"created_by_user_id\": \"user@company.com\",\n      \"created_time\": \"2024-01-01T10:00:00.000Z\",\n      \"default_value\": \"option1\",\n      \"description\": \"Custom field to tag experiments owned by the analytics team\",\n      \"entity_type\": \"flag\",\n      \"field_type\": \"text\",\n      \"id\": 12345,\n      \"key\": \"analytics_team\",\n      \"name\": \"Analytics Team\",\n      \"project_id\": 98765,\n      \"required\": false,\n      \"updated_time\": \"2024-01-01T10:00:00.000Z\",\n      \"validation\": {\n        \"allow_multi_select\": false,\n        \"decimal_places\": 2,\n        \"field_options\": [\n          \"\"\n        ],\n        \"max\": 100,\n        \"max_length\": 255,\n        \"min\": 1,\n        \"regex\": \"^[A-Za-z0-9_-]+$\",\n        \"use_thousand_separator\": true\n      }\n    }\n  ],\n  \"last_url\": {},\n  \"next_url\": {},\n  \"page\": 5,\n  \"prev_url\": {},\n  \"total_count\": 20,\n  \"total_pages\": 10,\n  \"url\": {}\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Malformed requests and invalid parameter names and types\n"
        },
        {
          "id": "response-2-401",
          "language": "401",
          "code": "// Invalid credentials\n"
        },
        {
          "id": "response-3-403",
          "language": "403",
          "code": "// Do not have permission to perform the operation\n"
        },
        {
          "id": "response-4-404",
          "language": "404",
          "code": "// Not found. No content\n"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}