rejectCall method

Future<void> rejectCall({
  1. required String callId,
  2. int? statusCode,
})

Reject an incoming call with an optional SIP status code. Default server behavior is 603 (Decline) if statusCode is omitted.

POST /v1/realtime/calls/{call_id}/reject

Implementation

Future<void> rejectCall({
  required String callId,
  int? statusCode, // e.g. 486 (Busy Here), 603 (Decline)
}) async {
  final body = <String, dynamic>{};
  if (statusCode != null) body['status_code'] = statusCode;

  final res = await postJson('/realtime/calls/$callId/reject', body);
  if (res.statusCode != 200) {
    throw OpenAIRequestException.fromHttpResponse(res);
  }
}