microsoft-foundry.rest.security.o-auth2-auth
Realtime
Transfer a SIP call
POST
/openai/v1/realtime/calls/{call_id}/refer
Transfers an active SIP call to a new destination using the SIP REFER verb.
Path parameters
call_id
string
required
The identifier for the call provided in the
realtime.call.incoming
webhook.
Request Body
Destination URI for the REFER request.
Content-Type: application/json
target_uri
string
required
URI that should appear in the SIP Refer-To header. Supports values like tel:+14155550123 or sip:agent\@example.com.
Responses
The request has succeeded.
Request
curl -X POST https://api.openai.com/v1/realtime/calls/$CALL_ID/refer \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"target_uri": "tel:+14155550123"}'
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});
await client.realtime.calls.refer('call_id', { target_uri: 'tel:+14155550123' });
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
)
client.realtime.calls.refer(
call_id="call_id",
target_uri="tel:+14155550123",
)
package main
import (
"context"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
"github.com/openai/openai-go/realtime"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("My API Key"),
)
err := client.Realtime.Calls.Refer(
context.TODO(),
"call_id",
realtime.CallReferParams{
TargetUri: "tel:+14155550123",
},
)
if err != nil {
panic(err.Error())
}
}
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.realtime.calls.CallReferParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
CallReferParams params = CallReferParams.builder()
.callId("call_id")
.targetUri("tel:+14155550123")
.build();
client.realtime().calls().refer(params);
}
}
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
result = openai.realtime.calls.refer("call_id", target_uri: "tel:+14155550123")
puts(result)