How to connect Vapi to a Costa Rica number over a SIP trunk
Step-by-step setup for Vapi on a SIP.cr trunk with a +506, 800 or 0800 number: which value goes in each field and what to check if the first call fails.
To connect Vapi to a Costa Rica phone number, create a SIP.cr trunk of type Vapi, copy its SIP server address, port, username and password into a Vapi credential for your own SIP trunk, add a phone number on that credential in Vapi, and point a +506, 800 or 0800 number from SIP.cr at a trunk group that contains the trunk. After that, calls to the number reach your Vapi assistant, and outbound calls from Vapi leave with one of your own numbers as caller ID.
This article walks through the setup in order, shows which value goes into which Vapi field, and lists what to check when the first call does not go through.
What you need before you start
- An active SIP.cr account. A person reviews each new account (company details and legal representative). Service starts once a payment method is on file and there is credit.
- A Vapi account and an assistant you want to put on the phone network.
- Access to the Vapi API. Vapi adds an external SIP trunk through its API, not through a single form, so have your Vapi API key ready. Vapi's own guide is at docs.vapi.ai.
- A rough idea of how many calls will run at the same time. That number becomes the trunk's channel count.
Step by step
- Create the trunk in SIP.cr. In SIP trunks, choose New trunk and pick Vapi. Choosing Vapi sets the trunk to username and password authentication, with credentials that SIP.cr generates. Set the number of simultaneous calls you need.
- Open the trunk page. It lists each value under the name Vapi uses for it, so you do not have to guess which field is which.
- Create the credential in Vapi. Following Vapi's guide, send
POST /credentialwith the providerbyo-sip-trunkand the values from the trunk page (see the table below). - Create the phone number in Vapi. With the credential in place, send
POST /phone-numberso Vapi has a number on that trunk to attach to your assistant. Use the exact request format from Vapi's guide. - Buy a Costa Rica number in SIP.cr. In Numbers, pick a +506 geographic number, a national toll-free 800 number or an international toll-free 0800 number, and point it at a trunk group that contains the Vapi trunk.
- Make a test call. Call the number from a phone, or place an outbound call from Vapi. The trunk page in SIP.cr shows the last call and how it ended.
Field mapping
The left column uses the names in Vapi's published guide. The values come from your trunk page in SIP.cr.
| Field in Vapi | Value from your SIP.cr trunk |
|---|---|
gateways[].ip | SIP server address |
gateways[].port | SIP port |
outboundAuthenticationPlan.authUsername | Trunk username |
outboundAuthenticationPlan.authPassword | Trunk password |
Field names come from Vapi's guide and can change when Vapi updates its product. If a label in Vapi does not match this table, follow Vapi's current guide and write to [email protected] so the mapping can be checked.
Treat the trunk password like any other secret: keep it in your secrets manager or environment variables, not in scripts you share or commit.
Inbound and outbound: how the number fits in
The number and the trunk are separate objects in SIP.cr, which is useful once you have more than one agent.
- Inbound. A number is routed to a trunk group, and the trunk group contains one or more trunks. Trunk groups support ordered failover for inbound calls, so you can decide which trunk receives the call first.
- Outbound. When Vapi places a call through the trunk, the caller ID is one of your account's own numbers. Callers in Costa Rica see a local or toll-free number they can call back, instead of a foreign one.
If you run several assistants, or several platforms, you can create one trunk per agent and keep numbers, channels and billing in one account.
Sizing channels
Each trunk has between 1 and 1,000 channels, and each channel carries one call at a time. Start from the peak number of simultaneous calls you expect, inbound and outbound together on that trunk. If a campaign or a busy period needs more, change the channel count from the portal or through the API; you do not need to recreate the trunk.
If you see calls failing only at busy times while quiet hours work fine, compare the number of simultaneous calls with the channel count first.
When the first call fails
Start in the SIP.cr portal, not in Vapi. Every call to and from Vapi has a record with its timeline, hangup cause, audio quality figures and result. The hangup cause is explained in plain words with what to check.
| What you see | Likely cause | What to check |
|---|---|---|
| No call record at all for an outbound attempt | The request never reached SIP.cr | Server address and port in the Vapi credential; that the credential is the one attached to the phone number |
| Call rejected for authentication | Wrong username or password | Copy both again from the trunk page; watch for extra spaces |
| Inbound calls do not reach Vapi | Routing | The SIP.cr number points at a trunk group that contains the Vapi trunk; the phone number exists on the Vapi side |
| Failures only at peak times | Not enough channels | Raise the channel count on the trunk |
| Call connects but audio is poor | Network quality | MOS, jitter and packet loss on the call record |
Two more points from the SIP.cr guides are worth knowing. The trunk supports the G.711 and Opus codecs. And a platform that requires TLS with SRTP, or that sends calls from many IP addresses, should be confirmed with [email protected] before you go live.
Automating the setup
Everything in the portal is also available over the REST API at https://sip.cr/api/v1, with a bearer API key. That lets you script the SIP.cr side of the same flow you script on the Vapi side:
/api/v1/trunksto create a trunk and change its channels./api/v1/trunk-groupsto group trunks with ordered failover./api/v1/numbersto search stock by area code, buy a number and route it./api/v1/callsand/api/v1/statsto read call records, answer rate and average duration.
If you build with Claude Code, Cursor or VS Code, the MCP server at https://sip.cr/mcp lets your coding agent read trunks, numbers and recent calls while it works on the Vapi integration, using the same API key. For event-driven logic, SIP.cr can post signed webhooks (call.initiated, call.answered, call.completed, call.failed) when the call record arrives right after the call ends.
A short checklist before going live
- The trunk was created with the Vapi type and the channel count matches your expected peak.
- The Vapi credential uses the server address, port, username and password from the trunk page.
- The Vapi phone number is attached to the assistant you want callers to reach.
- The SIP.cr number points at a trunk group that contains the Vapi trunk.
- One inbound and one outbound test call appear in the SIP.cr call records with the result you expected.
The full field list and setup steps are in the Vapi integration guide on SIP.cr.