Subscriptions
GET Get current subscription
https://focus.toggl.com/api/organizations/{organization_id}/subscriptions/current
Get current subscription.
- cURL
- Go
- Ruby
- JavaScript
- Python
- Rust
curl https://focus.toggl.com/api/organizations/{organization_id}/subscriptions/current \
-H "Content-Type: application/json"
req, err := http.NewRequest(http.MethodGet,
"https://focus.toggl.com/api/organizations/{organization_id}/subscriptions/current")
if err != nil {
print(err)
}
req.Header.Set("Content-Type", "application/json; charset=utf-8")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
print(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
print(err)
}
fmt.Print(string(body))
require 'net/http'
require 'uri'
require 'json'
uri = URI('https://focus.toggl.com/api/organizations/{organization_id}/subscriptions/current')
http = Net::HTTP.new(uri.host, uri.port)
req = Net::HTTP::Get.new(uri.path)
req['Content-Type'] = "application/json"
res = http.request(req)
puts JSON.parse(res.body)
fetch("https://focus.toggl.com/api/organizations/{organization_id}/subscriptions/current", {
method: "GET",
headers: {
"Content-Type": "application/json"
},
})
.then((resp) => resp.json())
.then((json) => {
console.log(json);
})
.catch(err => console.error(err));
import requests
from base64 import b64encode
data = requests.get('https://focus.toggl.com/api/organizations/{organization_id}/subscriptions/current', headers={'content-type': 'application/json'})
print(data.json())
extern crate tokio;
extern crate serde_json;
use reqwest::{Client};
use reqwest::header::{CONTENT_TYPE};
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let json = client.request(Method::GET, "https://focus.toggl.com/api/organizations/{organization_id}/subscriptions/current".to_string())
.header(CONTENT_TYPE, "application/json")
.send()
.await?
.json()
.await?;
println!("{:#?}", json);
Ok(())
}
Parameters
Path
| name | type | required | description |
|---|---|---|---|
| organization_id | integer | true | organization ID |
Response
200
| Name | Type | Description |
|---|---|---|
| organization_id | integer | - |
| price | object | - |
| product | object | - |
| subscription | object | - |
| subscription_item | object | - |
| track_subscription | object | - |
price
| Name | Type | Description |
|---|---|---|
| billing_period_in_months | integer | - |
| cost_in_cents | integer | - |
| currency | string | - |
| tag | string | - |
| track_pricing_plan_id | integer | - |
product
| Name | Type | Description |
|---|---|---|
| handle | string | - |
| name | string | - |
| site | string | - |
| toggl_product_id | string | - |
| track_enterprise | boolean | - |
| track_plan_id | integer | - |
subscription
| Name | Type | Description |
|---|---|---|
| customer | object | - |
| id | string | - |
| payment_failed | boolean | - |
| state | string | - |
| url | string | - |
customer
| Name | Type | Description |
|---|---|---|
| id | string | - |
| url | string | - |
subscription_item
| Name | Type | Description |
|---|---|---|
| quantity | integer | - |
| updated_at | string | - |
track_subscription
| Name | Type | Description |
|---|---|---|
| cancel_date | string | - |
| current_period_ends_at | string | - |
| current_period_starts_at | string | - |
| end_date | string | - |
| payment_failed | boolean | - |
| start_date | string | - |
| subscription_created_at | string | - |
| subscription_updated_at | string | - |
| trial | object | - |
trial
| Name | Type | Description |
|---|---|---|
| available | boolean | - |
| end_date | string | - |
| start_date | string | - |
| trial_plan_id | integer | - |
400
Invalid request
403
Insufficient permissions
500
Internal Server Error
GET Get current trial
https://focus.toggl.com/api/organizations/{organization_id}/subscriptions/trials/current
Get the current active trial for the Focus product.
- cURL
- Go
- Ruby
- JavaScript
- Python
- Rust
curl https://focus.toggl.com/api/organizations/{organization_id}/subscriptions/trials/current \
-H "Content-Type: application/json"
req, err := http.NewRequest(http.MethodGet,
"https://focus.toggl.com/api/organizations/{organization_id}/subscriptions/trials/current")
if err != nil {
print(err)
}
req.Header.Set("Content-Type", "application/json; charset=utf-8")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
print(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
print(err)
}
fmt.Print(string(body))
require 'net/http'
require 'uri'
require 'json'
uri = URI('https://focus.toggl.com/api/organizations/{organization_id}/subscriptions/trials/current')
http = Net::HTTP.new(uri.host, uri.port)
req = Net::HTTP::Get.new(uri.path)
req['Content-Type'] = "application/json"
res = http.request(req)
puts JSON.parse(res.body)
fetch("https://focus.toggl.com/api/organizations/{organization_id}/subscriptions/trials/current", {
method: "GET",
headers: {
"Content-Type": "application/json"
},
})
.then((resp) => resp.json())
.then((json) => {
console.log(json);
})
.catch(err => console.error(err));
import requests
from base64 import b64encode
data = requests.get('https://focus.toggl.com/api/organizations/{organization_id}/subscriptions/trials/current', headers={'content-type': 'application/json'})
print(data.json())
extern crate tokio;
extern crate serde_json;
use reqwest::{Client};
use reqwest::header::{CONTENT_TYPE};
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let json = client.request(Method::GET, "https://focus.toggl.com/api/organizations/{organization_id}/subscriptions/trials/current".to_string())
.header(CONTENT_TYPE, "application/json")
.send()
.await?
.json()
.await?;
println!("{:#?}", json);
Ok(())
}
Parameters
Path
| name | type | required | description |
|---|---|---|---|
| organization_id | integer | true | organization ID |
Response
200
Current active trial
| Name | Type | Description |
|---|---|---|
| id | integer | - |
| organization_id | integer | - |
| plan_id | integer | - |
| plan_name | string | - |
| product_handle | string | - |
| toggl_product_name | string | - |
| trial_cancels_at | string | - |
| trial_created_at | string | - |
| trial_deleted_at | string | - |
| trial_ended_at | string | - |
| trial_started_at | string | - |
| trial_type | string | - |
204
No active trial found
400
Invalid request
404
Subscription not found
500
Internal server error
POST Upserts a trial
https://focus.toggl.com/api/organizations/{organization_id}/workspaces/{workspace_id}/subscriptions/upsert-forced-trial
Creates or updates a trial for the organization based on workspace data and Plan import history.
- cURL
- Go
- Ruby
- JavaScript
- Python
- Rust
curl -X POST https://focus.toggl.com/api/organizations/{organization_id}/workspaces/{workspace_id}/subscriptions/upsert-forced-trial \
-H "Content-Type: application/json" \
-d '\{"plan_workspace_id":"integer"\}'
bytes, err := json.Marshal('\{"plan_workspace_id":"integer"\}')
if err != nil {
print(err)
}
req, err := http.NewRequest(http.MethodPost,
"https://focus.toggl.com/api/organizations/{organization_id}/workspaces/{workspace_id}/subscriptions/upsert-forced-trial", bytes.NewBuffer(bytes))
if err != nil {
print(err)
}
req.Header.Set("Content-Type", "application/json; charset=utf-8")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
print(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
print(err)
}
fmt.Print(string(body))
require 'net/http'
require 'uri'
require 'json'
uri = URI('https://focus.toggl.com/api/organizations/{organization_id}/workspaces/{workspace_id}/subscriptions/upsert-forced-trial')
http = Net::HTTP.new(uri.host, uri.port)
req = Net::HTTP::Post.new(uri.path)
req['Content-Type'] = "application/json"
req.body = \{"plan_workspace_id":"integer"\}.to_json
res = http.request(req)
puts JSON.parse(res.body)
fetch("https://focus.toggl.com/api/organizations/{organization_id}/workspaces/{workspace_id}/subscriptions/upsert-forced-trial", {
method: "POST",
body: \{"plan_workspace_id":"integer"\},
headers: {
"Content-Type": "application/json"
},
})
.then((resp) => resp.json())
.then((json) => {
console.log(json);
})
.catch(err => console.error(err));
import requests
from base64 import b64encode
data = requests.post('https://focus.toggl.com/api/organizations/{organization_id}/workspaces/{workspace_id}/subscriptions/upsert-forced-trial', json=\{"plan_workspace_id":"integer"\}, headers={'content-type': 'application/json'})
print(data.json())
extern crate tokio;
extern crate serde_json;
use reqwest::{Client};
use reqwest::header::{CONTENT_TYPE};
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let json = client.request(Method::POST, "https://focus.toggl.com/api/organizations/{organization_id}/workspaces/{workspace_id}/subscriptions/upsert-forced-trial".to_string())
.json(&serde_json::json!(\{"plan_workspace_id":"integer"\}))
.header(CONTENT_TYPE, "application/json")
.send()
.await?
.json()
.await?;
println!("{:#?}", json);
Ok(())
}
Parameters
Path
| name | type | required | description |
|---|---|---|---|
| organization_id | integer | true | organization ID |
| workspace_id | integer | true | workspace ID |
Body
| Name | Type | Description |
|---|---|---|
| plan_workspace_id | integer | - |
Response
200
Trial was created or updated
| Name | Type | Description |
|---|---|---|
| id | integer | - |
| organization_id | integer | - |
| plan_id | integer | - |
| plan_name | string | - |
| product_handle | string | - |
| toggl_product_name | string | - |
| trial_cancels_at | string | - |
| trial_created_at | string | - |
| trial_deleted_at | string | - |
| trial_ended_at | string | - |
| trial_started_at | string | - |
| trial_type | string | - |
204
No trial created or updated (existing unchanged trial, paid subscription, or no eligible trial)
400
Invalid request
409
Forced trial already exists or org has active subscription
500
Internal server error