Skip to content

ShipOS API v2API משלוחים אחד לכל חברות השליחויות

יצירת משלוחים ותוויות, מעקב אחר מסירות, איתור נקודות איסוף וקבלת webhooks חתומים — עבור כל חברות השליחויות של ShipOS, מאחורי חוזה אחיד ומתוּעד גרסה.

ShipOSShipOS

שתי קריאות עד לתווית הראשונה שלכם

bash
# 1. אתרו את חשבון חברת השליחויות שלכם
curl --location 'https://app.shipos.co.il/api/v2/licenses' \
--header 'X-Client-Id: {client_id}' \
--header 'X-Client-Secret: {client_secret}' \
--header 'Accept: application/json'

# 2. צרו את המשלוח
curl --location 'https://app.shipos.co.il/api/v2/shipments' \
--header 'X-Client-Id: {client_id}' \
--header 'X-Client-Secret: {client_secret}' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: order-10052-attempt-1' \
--data '{
  "license_key": "{license_key}",
  "ship_data": {
    "contact_name": "ישראל ישראלי",
    "contact_phone": "0501234567",
    "street": "הרצל",
    "number": "12",
    "city": "תל אביב",
    "type": "1",
    "return": "1",
    "packages": 1
  },
  "order": {
    "id": "10052",
    "shipping": { "first_name": "ישראל", "last_name": "ישראלי" },
    "order_items": []
  }
}'
js
// Node.js 18+ / דפדפנים — בלי תלויות
const baseUrl = 'https://app.shipos.co.il/api/v2'
const auth = {
  'X-Client-Id': process.env.SHIPOS_CLIENT_ID,
  'X-Client-Secret': process.env.SHIPOS_CLIENT_SECRET,
}

// 1. אתרו את חשבון חברת השליחויות שלכם
const licensesRes = await fetch(`${baseUrl}/licenses`, {
  headers: { ...auth, Accept: 'application/json' },
})
const { data: licenses } = await licensesRes.json()

// 2. צרו את המשלוח
const shipmentRes = await fetch(`${baseUrl}/shipments`, {
  method: 'POST',
  headers: {
    ...auth,
    'Content-Type': 'application/json',
    'Idempotency-Key': 'order-10052-attempt-1',
  },
  body: JSON.stringify({
    license_key: licenses[0].key,
    ship_data: {
      contact_name: 'ישראל ישראלי', contact_phone: '0501234567',
      street: 'הרצל', number: '12', city: 'תל אביב',
      type: '1', return: '1', packages: 1,
    },
    order: {
      id: '10052',
      shipping: { first_name: 'ישראל', last_name: 'ישראלי' },
      order_items: [],
    },
  }),
})
const { data: shipment } = await shipmentRes.json()

console.log(shipment.uuid, shipment.tracking_code)
php
<?php
// composer require guzzlehttp/guzzle

$client = new \GuzzleHttp\Client([
    'base_uri' => 'https://app.shipos.co.il/api/v2/',
    'headers' => [
        'X-Client-Id' => getenv('SHIPOS_CLIENT_ID'),
        'X-Client-Secret' => getenv('SHIPOS_CLIENT_SECRET'),
        'Accept' => 'application/json',
    ],
]);

// 1. אתרו את חשבון חברת השליחויות שלכם
$licenses = json_decode($client->get('licenses')->getBody()->getContents(), true)['data'];

// 2. צרו את המשלוח
$response = $client->post('shipments', [
    'headers' => ['Idempotency-Key' => 'order-10052-attempt-1'],
    'json' => [
        'license_key' => $licenses[0]['key'],
        'ship_data' => [
            'contact_name' => 'ישראל ישראלי', 'contact_phone' => '0501234567',
            'street' => 'הרצל', 'number' => '12', 'city' => 'תל אביב',
            'type' => '1', 'return' => '1', 'packages' => 1,
        ],
        'order' => [
            'id' => '10052',
            'shipping' => ['first_name' => 'ישראל', 'last_name' => 'ישראלי'],
            'order_items' => [],
        ],
    ],
]);

$shipment = json_decode($response->getBody()->getContents(), true)['data'];

echo $shipment['uuid'], ' ', $shipment['tracking_code'], PHP_EOL;
php
<?php

use Illuminate\Support\Facades\Http;

$shipos = Http::withHeaders([
    'X-Client-Id' => config('services.shipos.client_id'),
    'X-Client-Secret' => config('services.shipos.client_secret'),
])->acceptJson()->baseUrl('https://app.shipos.co.il/api/v2');

// 1. אתרו את חשבון חברת השליחויות שלכם
$licenses = $shipos->get('licenses')->throw()->json('data');

// 2. צרו את המשלוח
$shipment = $shipos->withHeaders(['Idempotency-Key' => 'order-10052-attempt-1'])
    ->post('shipments', [
        'license_key' => $licenses[0]['key'],
        'ship_data' => [
            'contact_name' => 'ישראל ישראלי', 'contact_phone' => '0501234567',
            'street' => 'הרצל', 'number' => '12', 'city' => 'תל אביב',
            'type' => '1', 'return' => '1', 'packages' => 1,
        ],
        'order' => [
            'id' => '10052',
            'shipping' => ['first_name' => 'ישראל', 'last_name' => 'ישראלי'],
            'order_items' => [],
        ],
    ])
    ->throw()
    ->json('data');

logger()->info($shipment['uuid'].' '.$shipment['tracking_code']);
python
# pip install httpx
import os

import httpx

client = httpx.Client(
    base_url="https://app.shipos.co.il/api/v2",
    headers={
        "X-Client-Id": os.environ["SHIPOS_CLIENT_ID"],
        "X-Client-Secret": os.environ["SHIPOS_CLIENT_SECRET"],
        "Accept": "application/json",
    },
)

# 1. אתרו את חשבון חברת השליחויות שלכם
licenses = client.get("/licenses").raise_for_status().json()["data"]

# 2. צרו את המשלוח
response = client.post(
    "/shipments",
    headers={"Idempotency-Key": "order-10052-attempt-1"},
    json={
        "license_key": licenses[0]["key"],
        "ship_data": {
            "contact_name": "ישראל ישראלי", "contact_phone": "0501234567",
            "street": "הרצל", "number": "12", "city": "תל אביב",
            "type": "1", "return": "1", "packages": 1,
        },
        "order": {
            "id": "10052",
            "shipping": {"first_name": "ישראל", "last_name": "ישראלי"},
            "order_items": [],
        },
    },
)
shipment = response.raise_for_status().json()["data"]

print(shipment["uuid"], shipment["tracking_code"])
go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

const baseURL = "https://app.shipos.co.il/api/v2"

func call(method, path string, body []byte, extra map[string]string) map[string]any {
	req, _ := http.NewRequest(method, baseURL+path, bytes.NewReader(body))
	req.Header.Set("X-Client-Id", os.Getenv("SHIPOS_CLIENT_ID"))
	req.Header.Set("X-Client-Secret", os.Getenv("SHIPOS_CLIENT_SECRET"))
	req.Header.Set("Accept", "application/json")
	for name, value := range extra {
		req.Header.Set(name, value)
	}

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	var payload map[string]any
	if err := json.NewDecoder(res.Body).Decode(&payload); err != nil {
		panic(err)
	}
	return payload
}

func main() {
	// 1. אתרו את חשבון חברת השליחויות שלכם
	licenses := call("GET", "/licenses", nil, nil)["data"].([]any)
	licenseKey := licenses[0].(map[string]any)["key"]

	// 2. צרו את המשלוח
	body, _ := json.Marshal(map[string]any{
		"license_key": licenseKey,
		"ship_data": map[string]any{
			"contact_name": "ישראל ישראלי", "contact_phone": "0501234567",
			"street": "הרצל", "number": "12", "city": "תל אביב",
			"type": "1", "return": "1", "packages": 1,
		},
		"order": map[string]any{
			"id":          "10052",
			"shipping":    map[string]any{"first_name": "ישראל", "last_name": "ישראלי"},
			"order_items": []any{},
		},
	})
	shipment := call("POST", "/shipments", body, map[string]string{
		"Content-Type":    "application/json",
		"Idempotency-Key": "order-10052-attempt-1",
	})["data"].(map[string]any)

	fmt.Println(shipment["uuid"], shipment["tracking_code"])
}
java
// Java 17+ — java.net.http, בלי תלויות (פרסור עם Jackson/Gson)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class ShipOsFirstLabel {
    static final String BASE = "https://app.shipos.co.il/api/v2";
    static final HttpClient CLIENT = HttpClient.newHttpClient();

    static HttpRequest.Builder request(String path) {
        return HttpRequest.newBuilder(URI.create(BASE + path))
            .header("X-Client-Id", System.getenv("SHIPOS_CLIENT_ID"))
            .header("X-Client-Secret", System.getenv("SHIPOS_CLIENT_SECRET"))
            .header("Accept", "application/json");
    }

    public static void main(String[] args) throws Exception {
        // 1. אתרו את חשבון חברת השליחויות שלכם
        HttpResponse<String> licenses = CLIENT.send(
            request("/licenses").build(), HttpResponse.BodyHandlers.ofString());
        System.out.println(licenses.body()); // take a "key" from {"data":[...]}

        // 2. צרו את המשלוח
        String body = """
            {
              "license_key": "{license_key}",
              "ship_data": {
                "contact_name": "ישראל ישראלי", "contact_phone": "0501234567",
                "street": "הרצל", "number": "12", "city": "תל אביב",
                "type": "1", "return": "1", "packages": 1
              },
              "order": {
                "id": "10052",
                "shipping": { "first_name": "ישראל", "last_name": "ישראלי" },
                "order_items": []
              }
            }""";

        HttpResponse<String> shipment = CLIENT.send(
            request("/shipments")
                .header("Content-Type", "application/json")
                .header("Idempotency-Key", "order-10052-attempt-1")
                .POST(HttpRequest.BodyPublishers.ofString(body))
                .build(),
            HttpResponse.BodyHandlers.ofString());

        System.out.println(shipment.body()); // {"data":{"uuid":...,"tracking_code":...}}
    }
}
csharp
// .NET 8+ — System.Net.Http.Json
using System.Net.Http.Json;
using System.Text.Json;

using var http = new HttpClient
{
    BaseAddress = new Uri("https://app.shipos.co.il/api/v2/"),
};
http.DefaultRequestHeaders.Add("X-Client-Id",
    Environment.GetEnvironmentVariable("SHIPOS_CLIENT_ID"));
http.DefaultRequestHeaders.Add("X-Client-Secret",
    Environment.GetEnvironmentVariable("SHIPOS_CLIENT_SECRET"));
http.DefaultRequestHeaders.Add("Accept", "application/json");

// 1. אתרו את חשבון חברת השליחויות שלכם
var licenses = (await http.GetFromJsonAsync<JsonDocument>("licenses"))!
    .RootElement.GetProperty("data");

// 2. צרו את המשלוח
var payload = new
{
    license_key = licenses[0].GetProperty("key").GetString(),
    ship_data = new
    {
        contact_name = "ישראל ישראלי", contact_phone = "0501234567",
        street = "הרצל", number = "12", city = "תל אביב",
        type = "1", @return = "1", packages = 1,
    },
    order = new
    {
        id = "10052",
        shipping = new { first_name = "ישראל", last_name = "ישראלי" },
        order_items = Array.Empty<object>(),
    },
};

using var request = new HttpRequestMessage(HttpMethod.Post, "shipments")
{
    Content = JsonContent.Create(payload),
};
request.Headers.Add("Idempotency-Key", "order-10052-attempt-1");

var response = await http.SendAsync(request);
response.EnsureSuccessStatusCode();
var shipment = (await response.Content.ReadFromJsonAsync<JsonDocument>())!
    .RootElement.GetProperty("data");

Console.WriteLine($"{shipment.GetProperty("uuid").GetString()} " +
    $"{shipment.GetProperty("tracking_code").GetString()}");
ruby
require "net/http"
require "json"

auth = {
  "X-Client-Id" => ENV.fetch("SHIPOS_CLIENT_ID"),
  "X-Client-Secret" => ENV.fetch("SHIPOS_CLIENT_SECRET"),
  "Accept" => "application/json",
}

http = Net::HTTP.new("app.shipos.co.il", 443)
http.use_ssl = true

# 1. אתרו את חשבון חברת השליחויות שלכם
licenses = JSON.parse(
  http.request(Net::HTTP::Get.new("/api/v2/licenses", auth)).body
).fetch("data")

# 2. צרו את המשלוח
post = Net::HTTP::Post.new("/api/v2/shipments", auth.merge(
  "Content-Type" => "application/json",
  "Idempotency-Key" => "order-10052-attempt-1",
))
post.body = JSON.dump(
  license_key: licenses.first["key"],
  ship_data: {
    contact_name: "ישראל ישראלי", contact_phone: "0501234567",
    street: "הרצל", number: "12", city: "תל אביב",
    type: "1", return: "1", packages: 1,
  },
  order: {
    id: "10052",
    shipping: { first_name: "ישראל", last_name: "ישראלי" },
    order_items: [],
  },
)

shipment = JSON.parse(http.request(post).body).fetch("data")

puts "#{shipment["uuid"]} #{shipment["tracking_code"]}"
rust
// [dependencies]
// reqwest = { version = "0.12", features = ["json"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();
    let id = std::env::var("SHIPOS_CLIENT_ID")?;
    let secret = std::env::var("SHIPOS_CLIENT_SECRET")?;

    // 1. אתרו את חשבון חברת השליחויות שלכם
    let licenses: Value = client
        .get("https://app.shipos.co.il/api/v2/licenses")
        .header("X-Client-Id", &id)
        .header("X-Client-Secret", &secret)
        .header("Accept", "application/json")
        .send()
        .await?
        .error_for_status()?
        .json()
        .await?;

    // 2. צרו את המשלוח
    let shipment: Value = client
        .post("https://app.shipos.co.il/api/v2/shipments")
        .header("X-Client-Id", &id)
        .header("X-Client-Secret", &secret)
        .header("Accept", "application/json")
        .header("Idempotency-Key", "order-10052-attempt-1")
        .json(&json!({
            "license_key": licenses["data"][0]["key"],
            "ship_data": {
                "contact_name": "ישראל ישראלי", "contact_phone": "0501234567",
                "street": "הרצל", "number": "12", "city": "תל אביב",
                "type": "1", "return": "1", "packages": 1
            },
            "order": {
                "id": "10052",
                "shipping": { "first_name": "ישראל", "last_name": "ישראלי" },
                "order_items": []
            }
        }))
        .send()
        .await?
        .error_for_status()?
        .json()
        .await?;

    println!(
        "{} {}",
        shipment["data"]["uuid"], shipment["data"]["tracking_code"]
    );
    Ok(())
}

התגובה כוללת את ה-uuid של המשלוח, את קוד המעקב של חברת השליחויות ותווית מוכנה להדפסה. עברו על התהליך המלא — כולל תוויות, מעקב וטיפול בשגיאות — במדריך צרו את המשלוח הראשון שלכם.