- name
- telnyx-porting-in-javascript
- description
- Port phone numbers into Telnyx. Check portability, create port orders, upload LOA documents, and track porting status. This skill provides JavaScript SDK examples.
- metadata
- {"author":"telnyx","product":"porting-in","language":"javascript","generated_by":"telnyx-ext-skills-generator"}
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
# Telnyx Porting In - JavaScript
## Installation
```bash
npm install telnyx
```
## Setup
```javascript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
```
All examples below assume `client` is already initialized as shown above.
## List all porting events
Returns a list of all porting events.
`GET /porting/events`
```javascript
// Automatically fetches more pages as needed.
for await (const eventListResponse of client.porting.events.list()) {
console.log(eventListResponse);
}
```
## Show a porting event
Show a specific porting event.
`GET /porting/events/{id}`
```javascript
const event = await client.porting.events.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
console.log(event.data);
```
## Republish a porting event
Republish a specific porting event.
`POST /porting/events/{id}/republish`
```javascript
await client.porting.events.republish('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
```
## Preview the LOA configuration parameters
Preview the LOA template that would be generated without need to create LOA configuration.
`POST /porting/loa_configuration_preview`
```javascript
const response = await client.porting.loaConfigurations.preview0({
address: {
city: 'Austin',
country_code: 'US',
state: 'TX',
street_address: '600 Congress Avenue',
zip_code: '78701',
},
company_name: 'Telnyx',
contact: { email: 'testing@telnyx.com', phone_number: '+12003270001' },
logo: { document_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' },
name: 'My LOA Configuration',
});
console.log(response);
const content = await response.blob();
console.log(content);
```
## List LOA configurations
List the LOA configurations.
`GET /porting/loa_configurations`
```javascript
// Automatically fetches more pages as needed.
for await (const portingLoaConfiguration of client.porting.loaConfigurations.list()) {
console.log(portingLoaConfiguration.id);
}
```
## Create a LOA configuration
Create a LOA configuration.
`POST /porting/loa_configurations`
```javascript
const loaConfiguration = await client.porting.loaConfigurations.create({
address: {
city: 'Austin',
country_code: 'US',
state: 'TX',
street_address: '600 Congress Avenue',
zip_code: '78701',
},
company_name: 'Telnyx',
contact: { email: 'testing@telnyx.com', phone_number: '+12003270001' },
logo: { document_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' },
name: 'My LOA Configuration',
});
console.log(loaConfiguration.data);
```
## Retrieve a LOA configuration
Retrieve a specific LOA configuration.
`GET /porting/loa_configurations/{id}`
```javascript
const loaConfiguration = await client.porting.loaConfigurations.retrieve(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(loaConfiguration.data);
```
## Update a LOA configuration
Update a specific LOA configuration.
`PATCH /porting/loa_configurations/{id}`
```javascript
const loaConfiguration = await client.porting.loaConfigurations.update(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{
address: {
city: 'Austin',
country_code: 'US',
state: 'TX',
street_address: '600 Congress Avenue',
zip_code: '78701',
},
company_name: 'Telnyx',
contact: { email: 'testing@telnyx.com', phone_number: '+12003270001' },
logo: { document_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' },
name: 'My LOA Configuration',
},
);
console.log(loaConfiguration.data);
```
## Delete a LOA configuration
Delete a specific LOA configuration.
`DELETE /porting/loa_configurations/{id}`
```javascript
await client.porting.loaConfigurations.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
```
## Preview a LOA configuration
Preview a specific LOA configuration.
`GET /porting/loa_configurations/{id}/preview`
```javascript
const response = await client.porting.loaConfigurations.preview1(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(response);
const content = await response.blob();
console.log(content);
```
## List all porting orders
Returns a list of your porting order.
`GET /porting_orders`
```javascript
// Automatically fetches more pages as needed.
for await (const portingOrder of client.portingOrders.list()) {
console.log(portingOrder.id);
}
```
## Create a porting order
Creates a new porting order object.
`POST /porting_orders` — Required: `phone_numbers`
```javascript
const portingOrder = await client.portingOrders.create({
phone_numbers: ['+13035550000', '+13035550001', '+13035550002'],
});
console.log(portingOrder.data);
```
## Retrieve a porting order
Retrieves the details of an existing porting order.
`GET /porting_orders/{id}`
```javascript
const portingOrder = await client.portingOrders.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
console.log(portingOrder.data);
```
## Edit a porting order
Edits the details of an existing porting order.
`PATCH /porting_orders/{id}`
```javascript
const portingOrder = await client.portingOrders.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
console.log(portingOrder.data);
```
## Delete a porting order
Deletes an existing porting order.
`DELETE /porting_orders/{id}`
```javascript
await client.portingOrders.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
```
## Activate every number in a porting order asynchronously.
Activate each number in a porting order asynchronously.
`POST /porting_orders/{id}/actions/activate`
```javascript
const response = await client.portingOrders.actions.activate(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(response.data);
```
## Cancel a porting order
`POST /porting_orders/{id}/actions/cancel`
```javascript
const response = await client.portingOrders.actions.cancel('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
console.log(response.data);
```
## Submit a porting order.
Confirm and submit your porting order.
`POST /porting_orders/{id}/actions/confirm`
```javascript
const response = await client.portingOrders.actions.confirm('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
console.log(response.data);
```
## Share a porting order
Creates a sharing token for a porting order.
`POST /porting_orders/{id}/actions/share`
```javascript
const response = await client.portingOrders.actions.share('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
console.log(response.data);
```
## List all porting activation jobs
Returns a list of your porting activation jobs.
`GET /porting_orders/{id}/activation_jobs`
```javascript
// Automatically fetches more pages as needed.
for await (const portingOrdersActivationJob of client.portingOrders.activationJobs.list(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
)) {
console.log(portingOrdersActivationJob.id);
}
```
## Retrieve a porting activation job
Returns a porting activation job.
`GET /porting_orders/{id}/activation_jobs/{activationJobId}`
```javascript
const activationJob = await client.portingOrders.activationJobs.retrieve(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' },
);
console.log(activationJob.data);
```
## Update a porting activation job
Updates the activation time of a porting activation job.
`PATCH /porting_orders/{id}/activation_jobs/{activationJobId}`
```javascript
const activationJob = await client.portingOrders.activationJobs.update(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' },
);
console.log(activationJob.data);
```
## List additional documents
Returns a list of additional documents for a porting order.
`GET /porting_orders/{id}/additional_documents`
```javascript
// Automatically fetches more pages as needed.
for await (const additionalDocumentListResponse of client.portingOrders.additionalDocuments.list(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
)) {
console.log(additionalDocumentListResponse.id);
}
```
## Create a list of additional documents
Creates a list of additional documents for a porting order.
`POST /porting_orders/{id}/additional_documents`
```javascript
const additionalDocument = await client.portingOrders.additionalDocuments.create(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(additionalDocument.data);
```
## Delete an additional document
Deletes an additional document for a porting order.
`DELETE /porting_orders/{id}/additional_documents/{additional_document_id}`
```javascript
await client.portingOrders.additionalDocuments.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
});
```
## List allowed FOC dates
Returns a list of allowed FOC dates for a porting order.
`GET /porting_orders/{id}/allowed_foc_windows`
```javascript
const response = await client.portingOrders.retrieveAllowedFocWindows(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(response.data);
```
## List all comments of a porting order
Returns a list of all comments of a porting order.
`GET /porting_orders/{id}/comments`
```javascript
// Automatically fetches more pages as needed.
for await (const commentListResponse of client.portingOrders.comments.list(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
)) {
console.log(commentListResponse.id);
}
```
## Create a comment for a porting order
Creates a new comment for a porting order.
`POST /porting_orders/{id}/comments`
```javascript
const comment = await client.portingOrders.comments.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
console.log(comment.data);
```
## Download a porting order loa template
`GET /porting_orders/{id}/loa_template`
```javascript
const response = await client.portingOrders.retrieveLoaTemplate(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(response);
const content = await response.blob();
console.log(content);
```
## List porting order requirements
Returns a list of all requirements based on country/number type for this porting order.
`GET /porting_orders/{id}/requirements`
```javascript
// Automatically fetches more pages as needed.
for await (const portingOrderRetrieveRequirementsResponse of client.portingOrders.retrieveRequirements(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
)) {
console.log(portingOrderRetrieveRequirementsResponse.field_type);
}
```
## Retrieve the associated V1 sub_request_id and port_request_id
`GET /porting_orders/{id}/sub_request`
```javascript
const response = await client.portingOrders.retrieveSubRequest(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(response.data);
```
## List verification codes
Returns a list of verification codes for a porting order.
`GET /porting_orders/{id}/verification_codes`
```javascript
// Automatically fetches more pages as needed.
for await (const verificationCodeListResponse of client.portingOrders.verificationCodes.list(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
)) {
console.log(verificationCodeListResponse.id);
}
```
## Send the verification codes
Send the verification code for all porting phone numbers.
`POST /porting_orders/{id}/verification_codes/send`
```javascript
await client.portingOrders.verificationCodes.send('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
```
## Verify the verification code for a list of phone numbers
Verifies the verification code for a list of phone numbers.
`POST /porting_orders/{id}/verification_codes/verify`
```javascript
const response = await client.portingOrders.verificationCodes.verify(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
Voir sur GitHub