{"command":{"effect":"write","timeoutSeconds":30,"inputSchema":{"type":"object","description":"**This endpoint allows you to create a new segment.**\n\n\n  Valid operators for create and update depend on the type of the field for which you are searching.\n\n**Dates**\n- \"eq\", \"ne\", \"lt\" (before), \"gt\" (after)\n    - You may use MM/DD/YYYY for day granularity or an epoch for second granularity.\n- \"empty\", \"not_empty\"\n- \"is within\"\n    - You may use an [ISO 8601 date format](https://en.wikipedia.org/wiki/ISO_8601) or the # of days.\n\n**Text**\n- \"contains\"\n- \"eq\" (is/equals - matches the full field)\n- \"ne\" (is not/not equals - matches any field where the entire field is not the condition value)\n- \"empty\"\n- \"not_empty\"\n\n**Numbers**\n- \"eq\" (is/equals)\n- \"lt\" (is less than)\n- \"gt\" (is greater than)\n- \"empty\"\n- \"not_empty\"\n\n**Email Clicks and Opens**\n- \"eq\" (opened)\n- \"ne\" (not opened)\n\nAll field values must be a string.\n\n\nConditions using \"eq\" or \"ne\" for email clicks and opens should provide a \"field\" of either `clicks.campaign_identifier` or `opens.campaign_identifier`.\nThe condition value should be a string containing the id of a completed campaign.\n\n\nThe conditions list may contain multiple conditions, joined by an \"and\" or \"or\" in the \"and_or\" field.\n\nThe first condition in the conditions list must have an empty \"and_or\", and subsequent conditions must all specify an \"and_or\".","properties":{"headers":{"type":"object","properties":{"on-behalf-of":{"type":"string","description":"The `on-behalf-of` header allows you to make API calls from a parent account on behalf of the parent's Subusers or customer accounts. You will use the parent account's API key when using this header. When making a call on behalf of a customer account, the property value should be \"account-id\" followed by the customer account's ID (e.g., `on-behalf-of: account-id <account-id>`). When making a call on behalf of a Subuser, the property value should be the Subuser's username (e.g., `on-behalf-of: <subuser-username>`). See [**On Behalf Of**](https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/on-behalf-of) for more information."}},"required":[],"additionalProperties":false},"body":{"$ref":"#/definitions/ContactdbSegments"}},"required":[],"additionalProperties":false,"definitions":{"ContactdbSegments":{"title":"Create a Segment request","type":"object","properties":{"name":{"type":"string","description":"The name of this segment."},"list_id":{"type":"integer","description":"The list id from which to make this segment. Not including this ID will mean your segment is created from the main contactdb rather than a list."},"conditions":{"type":"array","description":"The conditions for a recipient to be included in this segment.","items":{"$ref":"#/definitions/ContactdbSegmentsConditions"}},"recipient_count":{"type":"number","description":"The count of recipients in this list. This is not included on creation of segments."}},"required":["name","conditions"],"examples":[{"name":"Last Name Miller","list_id":4,"conditions":[{"field":"last_name","value":"Miller","operator":"eq","and_or":""},{"field":"last_clicked","value":"01/02/2015","operator":"gt","and_or":"and"},{"field":"clicks.campaign_identifier","value":"513","operator":"eq","and_or":"or"}],"recipient_count":1234}]},"ContactdbSegmentsConditions":{"title":"ContactDB: Segments: Conditions","type":"object","properties":{"field":{"type":"string"},"value":{"type":"string"},"operator":{"allOf":[{"$ref":"#/definitions/Operator"},{"type":"string"}]},"and_or":{"allOf":[{"$ref":"#/definitions/AndOr"},{"type":"string"}]}},"required":["field","value","operator"]},"Operator":{"type":"string","enum":["eq","ne","lt","gt","contains"]},"AndOr":{"type":"string","enum":["and","or",""]}}},"name":"Create a Segment","id":"sendgrid.lmc_contactdb.createsegment","example":{},"maxRequests":1,"summary":false}}