# Custom Fields ## Add Key `v1.custom_fields.add_key(CustomFieldAddKeyParams**kwargs)` **post** `/v1/customFields/addKey` Add a key to the allow list for a given entity. There is a 100 character limit on custom field keys. ### Parameters - **enforce\_uniqueness:** `bool` - **entity:** `Literal["alert", "billable_metric", "charge", 15 more]` - `"alert"` - `"billable_metric"` - `"charge"` - `"commit"` - `"contract_credit"` - `"contract_product"` - `"contract"` - `"credit_grant"` - `"customer_plan"` - `"customer"` - `"discount"` - `"invoice"` - `"plan"` - `"professional_service"` - `"product"` - `"rate_card"` - `"scheduled_charge"` - `"subscription"` - **key:** `str` ### Example ```python from metronome import Metronome client = Metronome( bearer_token="My Bearer Token", ) client.v1.custom_fields.add_key( enforce_uniqueness=True, entity="customer", key="x_account_id", ) ``` ## Delete Values `v1.custom_fields.delete_values(CustomFieldDeleteValuesParams**kwargs)` **post** `/v1/customFields/deleteValues` Deletes one or more custom fields on an instance of a Metronome entity. ### Parameters - **entity:** `Literal["alert", "billable_metric", "charge", 15 more]` - `"alert"` - `"billable_metric"` - `"charge"` - `"commit"` - `"contract_credit"` - `"contract_product"` - `"contract"` - `"credit_grant"` - `"customer_plan"` - `"customer"` - `"discount"` - `"invoice"` - `"plan"` - `"professional_service"` - `"product"` - `"rate_card"` - `"scheduled_charge"` - `"subscription"` - **entity\_id:** `str` - **keys:** `List[str]` ### Example ```python from metronome import Metronome client = Metronome( bearer_token="My Bearer Token", ) client.v1.custom_fields.delete_values( entity="customer", entity_id="99594816-e8a5-4bca-be21-8d1de0f45120", keys=["x_account_id"], ) ``` ## List Keys `v1.custom_fields.list_keys(CustomFieldListKeysParams**kwargs) -> CustomFieldListKeysResponse` **post** `/v1/customFields/listKeys` List all active custom field keys, optionally filtered by entity type. ### Parameters - **next\_page:** `str` Cursor that indicates where the next page of results should start. - **entities:** `List[Literal["alert", "billable_metric", "charge", 15 more]]` Optional list of entity types to return keys for - `"alert"` - `"billable_metric"` - `"charge"` - `"commit"` - `"contract_credit"` - `"contract_product"` - `"contract"` - `"credit_grant"` - `"customer_plan"` - `"customer"` - `"discount"` - `"invoice"` - `"plan"` - `"professional_service"` - `"product"` - `"rate_card"` - `"scheduled_charge"` - `"subscription"` ### Returns - `class CustomFieldListKeysResponse` - **data:** `List[Data]` - **enforce\_uniqueness:** `bool` - **entity:** `Literal["alert", "billable_metric", "charge", 15 more]` - `"alert"` - `"billable_metric"` - `"charge"` - `"commit"` - `"contract_credit"` - `"contract_product"` - `"contract"` - `"credit_grant"` - `"customer_plan"` - `"customer"` - `"discount"` - `"invoice"` - `"plan"` - `"professional_service"` - `"product"` - `"rate_card"` - `"scheduled_charge"` - `"subscription"` - **key:** `str` - **next\_page:** `Optional[str]` ### Example ```python from metronome import Metronome client = Metronome( bearer_token="My Bearer Token", ) response = client.v1.custom_fields.list_keys( entities=["customer"], ) print(response.data) ``` ## Remove Key `v1.custom_fields.remove_key(CustomFieldRemoveKeyParams**kwargs)` **post** `/v1/customFields/removeKey` Remove a key from the allow list for a given entity. ### Parameters - **entity:** `Literal["alert", "billable_metric", "charge", 15 more]` - `"alert"` - `"billable_metric"` - `"charge"` - `"commit"` - `"contract_credit"` - `"contract_product"` - `"contract"` - `"credit_grant"` - `"customer_plan"` - `"customer"` - `"discount"` - `"invoice"` - `"plan"` - `"professional_service"` - `"product"` - `"rate_card"` - `"scheduled_charge"` - `"subscription"` - **key:** `str` ### Example ```python from metronome import Metronome client = Metronome( bearer_token="My Bearer Token", ) client.v1.custom_fields.remove_key( entity="customer", key="x_account_id", ) ``` ## Set Values `v1.custom_fields.set_values(CustomFieldSetValuesParams**kwargs)` **post** `/v1/customFields/setValues` Sets one or more custom fields on an instance of a Metronome entity. If a key/value pair passed in this request matches one already set on the entity, its value will be overwritten. Any key/value pairs that exist on the entity that do not match those passed in this request will remain untouched. This endpoint is transactional and will update all key/value pairs or no key/value pairs. Partial updates are not supported. There is a 200 character limit on custom field values. ### Parameters - **custom\_fields:** `Dict[str, str]` - **entity:** `Literal["alert", "billable_metric", "charge", 15 more]` - `"alert"` - `"billable_metric"` - `"charge"` - `"commit"` - `"contract_credit"` - `"contract_product"` - `"contract"` - `"credit_grant"` - `"customer_plan"` - `"customer"` - `"discount"` - `"invoice"` - `"plan"` - `"professional_service"` - `"product"` - `"rate_card"` - `"scheduled_charge"` - `"subscription"` - **entity\_id:** `str` ### Example ```python from metronome import Metronome client = Metronome( bearer_token="My Bearer Token", ) client.v1.custom_fields.set_values( custom_fields={ "x_account_id": "KyVnHhSBWl7eY2bl" }, entity="customer", entity_id="99594816-e8a5-4bca-be21-8d1de0f45120", ) ```