Skip to main content
POST
/
calls
/
upsert
JavaScript
import Moonbase from '@moonbaseai/sdk';

const client = new Moonbase({
  apiKey: process.env['MOONBASE_API_KEY'], // This is the default and can be omitted
});

const call = await client.calls.upsert({
  direction: 'incoming',
  participants: [
    { phone: '+14155551212', role: 'caller' },
    { phone: '+16505551212', role: 'callee' },
  ],
  provider: 'openphone',
  provider_id: 'openphone_id_000000000006',
  provider_status: 'completed',
  start_at: '2025-02-17T15:00:00.000Z',
  answered_at: '2025-02-17T15:01:00Z',
  end_at: '2025-02-17T15:30:00.000Z',
  provider_metadata: {
    answered_by: 'UShjUatqtF',
    user_id: 'UShjUatqtF',
    phone_number_id: 'PN72zMikBJ',
    conversation_id: 'CN3b48bcc423e772aeba377414a4fa6a06',
  },
});

console.log(call.id);
{
  "id": "1CLJt2v1MsDbov8DBEEeWH",
  "type": "call",
  "participants": [
    {
      "id": "1CLJt2v1rdcqdM6vZpPpjq",
      "type": "call_participant",
      "role": "caller",
      "phone": "+14155551212",
      "person": {
        "id": "1CLJt2v2MQ25Sn5dxQYzyP",
        "type": "item"
      }
    },
    {
      "id": "1CLJt2v271pTY4bHG7UQrc",
      "type": "call_participant",
      "role": "callee",
      "phone": "+16505551212",
      "person": {
        "id": "1CLJt2v465RQonW8pU77np",
        "type": "item"
      }
    }
  ],
  "created_at": "2025-02-17T16:00:00.000Z",
  "updated_at": "2025-02-17T16:00:00.000Z",
  "direction": "incoming",
  "start_at": "2025-02-17T15:00:00.000Z",
  "answered_at": "2025-02-17T15:01:00.000Z",
  "end_at": "2025-02-17T15:30:00.000Z",
  "provider": "openphone",
  "provider_id": "openphone_id_000000000006",
  "provider_status": "completed",
  "provider_metadata": {
    "answered_by": "UShjUatqtF",
    "user_id": "UShjUatqtF",
    "phone_number_id": "PN72zMikBJ",
    "conversation_id": "CN3b48bcc423e772aeba377414a4fa6a06"
  }
}

Authorizations

Authorization
string
header
required

Your Moonbase API key.

Body

application/json

The Call object to be created or updated.

Parameters for creating or updating a Call object.

direction
enum<string>
required

The direction of the call, either incoming or outgoing.

Available options:
incoming,
outgoing
start_at
string<date-time>
required

The time the call started, as an ISO 8601 timestamp in UTC.

provider
string
required

The name of the phone provider that handled the call (e.g., openphone).

provider_id
string
required

The unique identifier for the call from the provider's system.

provider_status
string
required

The status of the call.

participants
CallParticipantCreateParams · object[]
required

An array of participants involved in the call.

answered_at
string<date-time>

The time the call was answered, as an ISO 8601 timestamp in UTC.

end_at
string<date-time>

The time the call ended, as an ISO 8601 timestamp in UTC.

provider_metadata
object

A hash of additional metadata from the provider.

recordings
CallRecordingCreateParams · object[]

Any recordings associated with the call.

transcript
CallTranscriptCreateParams · object

A transcript of the call.

Response

Successful response.

The Call object represents a phone call that has been logged in the system. It contains details about the participants, timing, and outcome of the call.

type
string
required

String representing the object’s type. Always call for this object.

Allowed value: "call"
id
string
required

Unique identifier for the object.

direction
enum<string>
required

The direction of the call, either incoming or outgoing.

Available options:
incoming,
outgoing
start_at
string<date-time>
required

The time the call started, as an ISO 8601 timestamp in UTC.

provider
string
required

The name of the phone provider that handled the call.

provider_id
string
required

The unique identifier for the call from the provider's system.

provider_status
string
required

The current status of the call.

participants
CallParticipant · object[]
required

The participants involved in the call.

created_at
string<date-time>
required

Time at which the object was created, as an ISO 8601 timestamp in UTC.

updated_at
string<date-time>
required

Time at which the object was last updated, as an ISO 8601 timestamp in UTC.

answered_at
string<date-time>

The time the call was answered, if available, as an ISO 8601 timestamp in UTC.

end_at
string<date-time>

The time the call ended, if available, as an ISO 8601 timestamp in UTC.

provider_metadata
object

A hash of additional metadata from the provider.