POST /api/accounts/create_already_user.json
Creates a new account and associates it with an already existing user. The email and password required are the ones of your existing user.
Example Request
curl
curl --request POST \
--url 'https://account_name.app.invoicexpress.com/api/accounts/create_already_user.json?api_key=YOUR%20API%20KEY%20HERE' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{"account":{"first_name":"First name","last_name":"Last name","organization_name":"Company name","phone":"213456789","email":"someone@example.com","password":"123456","fiscal_id":"504123456","tax_country":"1","language":"pt","terms":"1","marketing":"foo"}}'
Ruby
require 'uri'
require 'net/http'
url = URI("https://account_name.app.invoicexpress.com/api/accounts/create_already_user.json?api_key=YOUR%20API%20KEY%20HERE")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request.body = "{\"account\":{\"first_name\":\"First name\",\"last_name\":\"Last name\",\"organization_name\":\"Company name\",\"phone\":\"213456789\",\"email\":\"someone@example.com\",\"password\":\"123456\",\"fiscal_id\":\"504123456\",\"tax_country\":\"1\",\"language\":\"pt\",\"terms\":\"1\",\"marketing\":\"foo\"}}"
response = http.request(request)
puts response.read_body
Node
var http = require("https");
var options = {
"method": "POST",
"hostname": "account_name.app.invoicexpress.com",
"port": null,
"path": "/api/accounts/create_already_user.json?api_key=YOUR%20API%20KEY%20HERE",
"headers": {
"accept": "application/json",
"content-type": "application/json"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ account:
{ first_name: 'First name',
last_name: 'Last name',
organization_name: 'Company name',
phone: '213456789',
email: 'someone@example.com',
password: '123456',
fiscal_id: '504123456',
tax_country: '1',
language: 'pt',
terms: '1',
marketing: 'foo' } }));
req.end();
Python
import http.client
conn = http.client.HTTPSConnection("account_name.app.invoicexpress.com")
payload = "{\"account\":{\"first_name\":\"First name\",\"last_name\":\"Last name\",\"organization_name\":\"Company name\",\"phone\":\"213456789\",\"email\":\"someone@example.com\",\"password\":\"123456\",\"fiscal_id\":\"504123456\",\"tax_country\":\"1\",\"language\":\"pt\",\"terms\":\"1\",\"marketing\":\"foo\"}}"
headers = {
'accept': "application/json",
'content-type': "application/json"
}
conn.request("POST", "/api/accounts/create_already_user.json?api_key=YOUR%20API%20KEY%20HERE", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://account_name.app.invoicexpress.com/api/accounts/create_already_user.json?api_key=YOUR%20API%20KEY%20HERE",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"account\":{\"first_name\":\"First name\",\"last_name\":\"Last name\",\"organization_name\":\"Company name\",\"phone\":\"213456789\",\"email\":\"someone@example.com\",\"password\":\"123456\",\"fiscal_id\":\"504123456\",\"tax_country\":\"1\",\"language\":\"pt\",\"terms\":\"1\",\"marketing\":\"foo\"}}",
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://account_name.app.invoicexpress.com/api/accounts/create_already_user.json?api_key=YOUR%20API%20KEY%20HERE"
payload := strings.NewReader("{\"account\":{\"first_name\":\"First name\",\"last_name\":\"Last name\",\"organization_name\":\"Company name\",\"phone\":\"213456789\",\"email\":\"someone@example.com\",\"password\":\"123456\",\"fiscal_id\":\"504123456\",\"tax_country\":\"1\",\"language\":\"pt\",\"terms\":\"1\",\"marketing\":\"foo\"}}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("accept", "application/json")
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Request Body
Name | Type | Required | Description |
---|---|---|---|
Account | Object | Required | Data of the account to be created, with your existing email and password |
first_name | String | The user’s first name. | |
last_name | String | The user’s last name. | |
organization_name | String | Required | The name of the company. |
phone | String | The account phone number. | |
email | String | Required | The account email. |
password | String | Required | The account password. |
fiscal_id | String | The company fiscal ID (vat number). The fiscal_id, if present, must be unique in the system. | |
tax_country | String | The account country. Options: 1 (Portugal); 2 (Ireland); 3 (UK). See the Appendix for more countries. | |
language | String | The account language. Options: pt (Portuguese); en (English); es (Spanish). | |
terms | String | Required | The terms and conditions. Options: 1 (Accepted); 0 (Not accepted). |
marketing | String | Signing up to receive the marketing newsletter. Options: 1 (Accepted); 0 (Not accepted). |
Example Request Body
{
"account": {
"first_name": "First name",
"last_name": "Last name",
"organization_name": "Company name",
"phone": "213456789",
"email": "someone@example.com",
"password": "123456",
"fiscal_id": "504123456",
"tax_country": "1",
"language": "pt",
"terms": "1",
"marketing": "0"
}
}
Responses
200 | SUCCESS Account created and associated with the given user | Accounts Create response |
400 | BAD REQUEST Some parameters were incorrect. | (Empty Response) |
Example Success Body Response
{
"account": {
"id": "Account ID",
"name": "Company name",
"url": "https://companyname.app.invoicexpress.com",
"api_key": "aa8e739bbcbb406c90eccbe0825e87c5c1c4c5a9",
"state": "active"
}
}