API Documentation Discrepancy – Creating Code Tool...
# support
m
I'm encountering an issue when creating a Code Tool via your API that contradicts your current documentation. According to your docs (https://docs.vapi.ai/tools/code-tool#creating-code-tools), the request should include fields like name, description, parameters, and environmentVariables. For example: json { "type": "code", "name": "get_customer", "description": "Retrieves customer information", "code": "...", "parameters": { ... }, "environmentVariables": [ ... ] } However, when I send a request with these fields, I receive a 400 error: text { "message": [ "property name should not exist", "property description should not exist", "property parameters should not exist" ], "error": "Bad Request", "statusCode": 400 } A minimal request without those fields succeeds: json { "type": "code", "code": "return { hello: \"world\" };" } I need to include description, parameters, and environmentVariables for my planned integration. Could you clarify the correct schema for creating Code Tools? If the API has changed, please update the documentation accordingly. Thank you for your help! Best regards,
c
Hi there, Thank you for your message. Our team is currently out of the office. We operate Monday through Friday, from 9:00 AM to 8:00 PM Pacific Standard Time (PST). We’ll get back to you as soon as possible during our normal business hours. If your message is urgent, please mark it accordingly or include “URGENT” in the subject line, and we’ll do our best to respond promptly. Warm regards, Vapi Customer Support Team
r
It looks like the API is validating against a newer schema than what’s currently shown in the docs, which is why fields like name, description, and parameters are getting rejected. That’s also why the minimal payload with just type and code works. For now, try creating the tool with the minimal schema and add the metadata when attaching it to the assistant. That usually avoids the 400 validation error. Are you creating the tool via the /tools endpoint or inside the assistant config? @Market_Mars
m
via the /tools endpoint. I will try your suggestion for now, hope the docs are update soon. Thanks!
r
Sounds good! That approach should work for now. The docs are being updated soon, but let me know how it goes I can share tips for adding metadata smoothly afterward. @Market_Mars