Writing OpenAI function-calling schemas for sales actions, with worked examples
An OpenAI function-calling schema is a JSON Schema object wrapped in three fields: a name the model calls, a description it routes on, and a strict flag that decides how hard the validation is.
Fathom is not open yet, so anything on this page about what it does is what it is being built to do.
The shape every function-calling schema has
If you came here for an example to copy, this is the shape. A function-calling schema is not a proprietary format: it is an ordinary JSON Schema object for the arguments, plus three fields that tell the model what the function is and when to reach for it.
The four fields
name: the identifier the model emits. Snake case, a verb, stable forever, because it ends up in your logs, your traces and your prompt evals.description: the only routing signal the model has. It is read on every single request, next to every other tool you registered, and it is where you say when not to call this function.parameters: a JSON Schema object. In practice alwaystype: object, withproperties,required, andadditionalProperties: false.strict: a boolean. Set it true and the API constrains the model's output to your schema, in exchange for accepting a restricted subset of JSON Schema.
Two container shapes, one inner schema
The Responses API takes a flat tool object: type: function, then name, description, parameters, strict as siblings. Chat Completions nests the same four fields inside a function key under type: function. The inner parameters object is identical in both, so write the schema once and let the container be a serialisation detail. Anthropic's Messages API takes the same three ideas with one rename, input_schema instead of parameters, and no strict flag at all.
How to read the worked schemas below
Everything below is about parameters and description, because those are the two fields that decide whether an agent writing to a sales system does the right thing or a plausible wrong thing. The three worked schemas are illustrative patterns, written by hand against the strict subset as the API documents it. Treat them as a template for your own action definitions, not as a transcript of what any particular generator emits, ours included. Whatever your generator produces, run it past the checklist at the end of this page before you paste it into an agent.
Where a copied schema example fails
Most schema examples in circulation are get-the-weather toys with one string argument. They survive a demo because there is nothing to get wrong. Sales actions have identifiers, enums, timestamps and optional fields, so the following failures show up on the first real call.
Optional parameters under strict mode
The strict subset requires that every key in properties also appears in required. A schema with six properties and three of them listed as required is rejected at request time, not at call time, so the symptom is a 400 on the API call rather than a bad tool call. The fix is not to drop the field: express it as a nullable type, type: ['string', 'null'], and keep it in required. The model then has a legal way to say nothing, and you can still distinguish absent from empty.
A missing additionalProperties: false
Without it, the strict subset will not accept the schema, and without strict mode the model is free to add keys. An agent that invents qualified_by: 'assistant' because the prompt mentioned attribution is a silent shape mismatch in your handler.
Descriptions written for humans
Qualifies a lead tells the model nothing it could not guess from the name. The useful content is the boundary: what this action is not for, what must already exist before it is called, and what the model should do instead when the precondition is missing.
Free text where an enum belongs
Give a deal stage a plain string and you will eventually store Closed Won (verbal). Enums are the cheapest correctness mechanism you have, and under strict mode they are enforced rather than suggested.
Identifiers with no stated format
If lead_id is described as the lead, the model will pass a company name. Say uuid, say it comes from a prior read, and say the action fails without it.
Writing one action schema, step by step
- Name the action as a verb the model can choose between
Six names sit in the same request.
qualify_leadandflag_churn_riskare distinguishable;update_leadandupdate_recordare not. If two names could plausibly serve the same intent, the model will pick by coin flip and your eval will blame the prompt. - Write the description as routing instructions
One sentence on what it writes, one on the precondition, one on the exclusion. For example: records a qualification decision on an existing lead; requires a lead id from a prior read; do not use to create a lead or to change a deal stage.
- Type every parameter, then narrow it
Start from
string,integer,boolean, then addenumfor closed sets,format: uuidin the description for identifiers,minimumandmaximumfor scores, andformat: date-timefor timestamps. Narrowing is how you stop writing defensive code in the handler. - Decide required versus nullable before you set strict
List every property in
required. For anything genuinely optional, widen the type withnullinstead of removing it from the list. Then decide what a null means in your storage layer, because the model will send nulls liberally. - Close the object
Set
additionalProperties: falseon the root object and on every nested object. Nested objects are the common miss, and a nested object that is still open defeats the point of the strict flag on the root. - Mirror the schema in the server validator
Strict mode constrains the model, not the network. Anything can POST to your endpoint: a retry from a queue, a replayed trace, a human with curl. The schema is a contract for the model and the validator is the contract for the request, and they have to be generated from the same definition or they drift.
- Force the call and diff the arguments
Send one request with
tool_choicepinned to the function name and a prompt that supplies every value, then diff the returned arguments against what you expected. Forcing removes routing from the test, so a failure here is a schema failure, which is what you want to isolate first.
Worked example one: qualify_lead
A classifying action, the hardest of the six, because it is the one with consequences for a person. Illustrative pattern, written by hand to the strict subset.
The schema
name:qualify_leaddescription: Record a qualification decision on an existing lead. Requires a lead id obtained from a prior read. Do not use to create a lead, and do not use to change a deal stage.parameters.type:objectlead_id:string. The uuid of an existing lead. Describe it as a uuid, or the model will pass a company name it read in the transcript.status:stringwithenum: ['qualified', 'disqualified', 'nurture']. Three values, no synonyms. If your funnel has a fourth, add it to the enum rather than letting prose leak in.score:integer,minimum: 0,maximum: 100. Bound it, and say in the description what the number is for, or you will get 0.85 rounded to 1.reason:type: ['string', 'null']. The optional field. Keep it inrequiredand allow null, per the strict subset.human_review_ack:boolean.lawful_basis:string.required: all six keys.additionalProperties:false.
Why the last two fields are in the schema at all
An automated qualification decision about a named person is exactly the category that Article 22 of the GDPR addresses, so the two fields that record a human acknowledgement and a lawful basis belong in the argument shape, not in a comment. Fathom enforces human_review_ack and lawful_basis server-side on qualify_lead, flag_churn_risk and assign_owner.
A design note follows from that. Either your orchestration layer injects those two values from state it already holds, and the model never invents them, or a human step sets them and the action runs after. Deciding which is your decision and your counsel's, not the schema's. What the API returns when one of the two is missing is covered on our page about errors an agent can parse.
Worked example two: advance_deal_stage
A state transition, which is a different risk profile from a classification: the danger is not who it affects, it is that it is not idempotent.
The schema
name:advance_deal_stagedescription: Move one deal to a named stage. Requires a deal id from a prior read. Use after a stage change has actually been agreed, not to record intent.deal_id:string, uuid of an existing deal.stage:stringwith anenumof your pipeline stages, spelled exactly as your storage layer spells them. This is the single highest-value enum in a sales schema, because stage strings are what every downstream report groups by.note:type: ['string', 'null']. Optional, nullable, still inrequired.additionalProperties:false.
The trade-off you are actually making
A narrow enum means the model cannot express a stage you did not anticipate. That is the point, and it is also the cost: when your pipeline changes, the schema has to be redeployed before the agent can use the new stage. The alternative, a free-text stage, moves the failure from a refused tool call to a silently wrong row, which is strictly worse because nothing alerts.
If your backend supports it, the second parameter worth considering is the expected current stage, so a retried call that arrives twice can be rejected rather than applied twice. Whether you can add that depends on your own write path. What you should not do is rely on the model to remember that it already called the function. Retries, parallel tool calls and re-planned turns all produce duplicate calls, and the schema cannot prevent them; only the handler can.
Worked example three: log_interaction and create_contact
The two high-frequency writes. These are the schemas an agent calls most often, so small looseness here compounds fastest.
log_interaction
contact_id:string, uuid of an existing contact.type:stringwithenum: ['call', 'email', 'meeting', 'note']. Four values covers most pipelines, and an unbounded type field is how you end up withEmail (outbound)andemail-outboundin the same column.occurred_at:string, described as an ISO 8601 timestamp in UTC. Say UTC in the description. Models are willing to emit local times and will not tell you which locale they chose.summary:string. The one field where free text is correct, because it is the field a human reads.metadata: if you add a nested object here, it needs its ownadditionalProperties: false, or strict mode will not take the schema.
create_contact
email:string, described as the primary identifier.name:string.account_id:type: ['string', 'null'], nullable because a contact can arrive before the account exists.
The duplicate-contact problem is not a schema problem
The most common complaint about agents writing to a sales system is duplicates. A description that says search for an existing contact by email before calling this action reduces the rate, and it does not solve it, because a model with a partial view of state will still guess wrong under retry. The fix is a uniqueness rule and a deterministic upsert in the write path. Put the instruction in the description because it is cheap, and then assume it will be ignored some of the time and design the endpoint accordingly.
The same tool in OpenAI and Anthropic form, field by field
| Concept | OpenAI function calling | Anthropic tool use |
|---|---|---|
| Tool identifier | name | name |
| Routing prose | description | description |
| Argument schema | parameters, a JSON Schema object | input_schema, a JSON Schema object |
| Constrained decoding flag | strict: true, requires every property in required and additionalProperties false | No equivalent flag, validate server-side |
| Container | Flat tool object in the Responses API, nested under a function key in Chat Completions | Flat entry in the tools array |
| Forcing one tool | tool_choice naming the function | tool_choice naming the tool |
| Arguments as received | A JSON string you parse | An already decoded object |
| Returning the result | A function call output referencing the call id | A tool result block referencing the tool use id |
One definition, two serialisers
Look at that table and the conclusion is structural: the two formats are the same information with different key names and a different validation posture. Which means maintaining two hand-written schema files is maintaining one fact in two places, and one fact in two places drifts.
The drift is not theoretical and it is not loud. You rename reason to disqualification_reason in the OpenAI file during a refactor. The Anthropic file keeps the old key. The Claude-backed agent keeps calling the tool with an argument your validator no longer recognises, and depending on how forgiving your handler is, it either returns a validation error the model cannot act on or writes a row with a null in it. Nobody notices until someone asks why half the disqualifications have no reason.
What the source of truth should contain
One definition per action, holding the name, the description, the parameter list with types and enums, the required set, and which parameters are nullable. Then two serialiser functions, one emitting the OpenAI shape, one emitting the Anthropic shape, and a third path that produces the server-side validator for the REST endpoint. Add a test that asserts the two serialised outputs describe the same field set, so a rename that touches one and not the other fails the build rather than production.
That is the pattern Fathom is built on: both formats derive from one internal action definition file, and the six actions exist as REST endpoints as well, so the tool definition and the endpoint contract come from the same definition rather than from two files maintained by hand. The REST side of that, endpoint by endpoint, is covered on our page about the six pre-built agent actions.
How many tools to hand one agent
Once the schemas are correct, the next decision is how many of them to register. There are two defensible answers and one that looks clever and is not.
Narrow verbs
Six named actions, each with a tight argument shape. The model's job is routing between six clearly separated intents, which is the task it is best at, and every argument is constrained by an enum or a type. The cost is that all six descriptions and schemas occupy context on every request, and adding a seventh makes the routing decision slightly harder.
One generic write tool
A single write_record with an object, a type and a payload. It keeps the tool list short and it moves the entire routing problem into a free-form payload, which is precisely the part the strict subset cannot usefully constrain. You end up validating the payload at runtime and returning errors the model has to interpret, which is slower and less reliable than refusing an illegal enum value at decode time. Choose this only when the set of writable shapes genuinely is open.
The clever answer that fails
Registering both, so the agent can fall back to the generic tool when the narrow one refuses. Now you have two paths to the same row, one of which skips whatever the narrow path enforces. If any of your actions carry required fields, a generic bypass makes those fields optional in practice, which defeats the reason they were required.
The reasoning that follows from all of this is unglamorous: keep the tool list small, keep each schema tight, and make the server the place where correctness is decided, because the server is the only component in the loop that cannot be talked out of it.
A pre-flight checklist before an agent runs on your schemas
Run this once per action, and again after any rename, whether you wrote the schema by hand or a generator wrote it for you.
- Every key in
propertiesappears inrequired, and optional fields are nullable types rather than absentees. additionalProperties: falseis set on the root object and on every nested object.- Every closed set is an
enum, spelled exactly as the storage layer spells it. - Every identifier's description says uuid and says where the value comes from.
- Every timestamp's description names the format and the timezone.
- The description says what the action is not for, and names the action to use instead.
- A forced call with
tool_choicereturns arguments that validate against the server-side validator, unmodified. - Each required field has a test that omits it and asserts the error names that field, so a model can retry with the fix rather than guessing.
- The OpenAI and Anthropic serialisations of the same action assert equal field sets in CI.
- Someone has written down what happens when the same call arrives twice.
The last two are the ones teams skip and the ones that cost the most later. A schema is a contract, and a contract maintained in two files by hand is not a contract, it is a coincidence.
Questions
How do I define a tool for function calling?
Give it a name in snake case, a description that states the precondition and the exclusion, and a parameters object written as JSON Schema with type: object, typed properties, a required list and additionalProperties: false. Set strict: true if you want the API to constrain the model's output, and remember that the strict subset requires every property to be listed in required.
Function calling or tool use, what is the difference?
Naming, mostly. OpenAI calls it function calling and puts the argument schema in parameters; Anthropic calls it tool use and puts it in input_schema with no strict flag. The JSON Schema in the middle is the same, which is why generating both from one definition is more reliable than maintaining two files.
Can a function-calling schema have optional parameters?
Not by omission when strict mode is on: every key in properties must appear in required. Model the field as a nullable type instead, for example type: ['string', 'null'], and treat a null as absent in your handler.
Do I still need server-side validation if the schema is strict?
Yes. Strict mode constrains what the model emits, not what reaches your endpoint. Queue retries, replayed traces and direct calls all bypass the model entirely, so the endpoint needs its own validation generated from the same definition as the schema.
Why would a sales action schema include compliance fields?
Because a classifying action about a named person is the kind of automated decision Article 22 of the GDPR addresses, and a field is auditable where a comment is not. Fathom enforces human_review_ack and lawful_basis server-side on qualify_lead, flag_churn_risk and assign_owner. Whether a given decision needs a human in the loop is a question for your own legal advice.
Where do Fathom's schemas come from?
One internal action definition file, serialised into the OpenAI function-calling format and the Anthropic tool-use format, served from /api/v1/actions/schemas. The same six actions are REST endpoints, so the tool definition and the endpoint contract come from the same source.
What does it cost to work through these examples against a real API?
The Developer plan is free and includes all six actions and both tool schema formats, which is enough to wire one agent loop end to end; limits and the paid tiers are on the pricing page. Fathom is pre-launch, so the waitlist comes first.