Skip to content
Branch: master
Find file Copy path
Find file Copy path
442 lines (331 sloc) 13.9 KB

Developer Portal API


To quickly play around with spaceship launch irb in your terminal and execute require "spaceship".


Note: If you use both the Developer Portal and App Store Connect API, you'll have to login on both, as the user might have different user credentials.

Spaceship::Portal.login("", "password")

Spaceship::Portal.select_team # call this method to let the user select a team


# Fetch all available apps
all_apps =

# Find a specific app based on the bundle identifier
app ="")

# Show the names of all your apps do |app|

# Create a new app
app =!(bundle_id: "com.krausefx.app_name", name: "fastlane App")

App Services

App Services are part of the application, however, they are one of the few things that can be changed about the app once it has been created.

Currently available services include (all require the Spaceship::Portal.app_service. prefix)



# Find a specific app based on the bundle identifier
app ="")

# Get detail informations (e.g. see all enabled app services)

# Enable HealthKit, but make sure HomeKit is disabled

App Groups

# Fetch all existing app groups
all_groups = Spaceship::Portal.app_group.all

# Find a specific app group, based on the identifier
group = Spaceship::Portal.app_group.find("")

# Show the names of all the groups
Spaceship::Portal.app_group.all.collect do |group|

# Create a new group
group = Spaceship::Portal.app_group.create!(group_id: "",
                                        name: "Another group")

# Associate an app with this group (overwrites any previous associations)
# Assumes app contains a fetched app, as described above
app = app.associate_groups([group])

iCloud Containers

# Fetch all existing containers
all_containers = Spaceship::Portal.cloud_container.all

# Find a specific container, based on the identifier
container = Spaceship::Portal.cloud_container.find("")

# Show the names of all the containers
Spaceship::Portal.cloud_container.all.collect do |container|

# Create a new iCloud Container
container = Spaceship::Portal.cloud_container.create!(identifier: "",
                                        name: "Another iCloud Container")

# Associate an app with this container (overwrites any previous associations)
# Assumes app contains a fetched app, as described above
app = app.associate_cloud_containers([container])

Apple Pay Merchants

# Fetch all existing merchants
all_merchants = Spaceship::Portal.merchant.all

# Find a specific merchant, based on the identifier
sandbox_merchant = Spaceship::Portal.merchant.find("")

# Show the names of all the merchants
Spaceship::Portal.merchant.all.collect do |merchant|

# Create a new merchant
another_merchant = Spaceship::Portal.merchant.create!(bundle_id: "", name: "Another merchant")

# Delete a merchant

# Associate an app with merchant/s (overwrites any previous associations)
# Assumes app contains a fetched app, as described above
app = app.associate_merchants([sandbox_merchant, production_merchant])


# Fetch all existing passbooks
all_passbooks = Spaceship::Portal.passbook.all

# Find a specific passbook, based on the identifier
passbook = Spaceship::Portal.passbook.find("")

# Create a new passbook
passbook = Spaceship::Portal.passbook.create!(bundle_id: '', name: 'Fastlane Passbook')

# Delete a passbook using his identifier
passbook = Spaceship::Portal.passbook.find("").delete!


# Fetch all available certificates (includes signing and push profiles)
certificates = Spaceship::Portal.certificate.all

Code Signing Certificates

# Production identities
prod_certs = Spaceship::Portal.certificate.production.all

# Development identities
dev_certs = Spaceship::Portal.certificate.development.all

# Download a certificate
cert_content =

Push Certificates

# Production push profiles
prod_push_certs = Spaceship::Portal.certificate.production_push.all

# Development push profiles
dev_push_certs = Spaceship::Portal.certificate.development_push.all

# Download a push profile
cert_content =

# Creating a push certificate

# Create a new certificate signing request
csr, pkey = Spaceship::Portal.certificate.create_certificate_signing_request

# Use the signing request to create a new push certificate
Spaceship::Portal.certificate.production_push.create!(csr: csr, bundle_id: "")

Create a Certificate

# Create a new certificate signing request
csr, pkey = Spaceship::Portal.certificate.create_certificate_signing_request

# Use the signing request to create a new distribution certificate
Spaceship::Portal.certificate.production.create!(csr: csr)

Provisioning Profiles

Receiving profiles

##### Finding #####

# Get all available provisioning profiles
profiles = Spaceship::Portal.provisioning_profile.all

# Get all App Store and Ad Hoc profiles
# Both app_store.all and ad_hoc.all return the same
# This is the case since September 2016, since the API has changed
# and there is no fast way to get the type when fetching the profiles
profiles_appstore_adhoc = Spaceship::Portal.provisioning_profile.app_store.all
profiles_appstore_adhoc = Spaceship::Portal.provisioning_profile.ad_hoc.all

# Get all Development profiles
profiles_dev = Spaceship::Portal.provisioning_profile.development.all

# Fetch all profiles for a specific app identifier for the App Store (Array of profiles)
filtered_profiles = Spaceship::Portal.provisioning_profile.app_store.find_by_bundle_id(bundle_id: "")

# Check if a provisioning profile is valid

# Verify that the certificate of the provisioning profile is valid

##### Downloading #####

# Download a profile
profile_content =

# Download a specific profile as file
matching_profiles = Spaceship::Portal.provisioning_profile.app_store.find_by_bundle_id(bundle_id: "")
first_profile = matching_profiles.first


Create a Provisioning Profile

# Choose the certificate to use
cert = Spaceship::Portal.certificate.production.all.first

# Create a new provisioning profile with a default name
# The name of the new profile is " AppStore"
profile = Spaceship::Portal.provisioning_profile.app_store.create!(bundle_id: "",
                                                         certificate: cert)

# AdHoc Profiles will add all devices by default
profile = Spaceship::Portal.provisioning_profile.ad_hoc.create!(bundle_id: "",
                                                      certificate: cert,
                                                             name: "Profile Name")

# Store the new profile on the filesystem

Repair all broken provisioning profiles

# Select all 'Invalid' or 'Expired' provisioning profiles
broken_profiles = Spaceship::Portal.provisioning_profile.all.find_all do |profile|
  # the below could be replaced with `!profile.valid? || !profile.certificate_valid?`, which takes longer but also verifies the code signing identity
  (profile.status == "Invalid" or profile.status == "Expired")

# Iterate over all broken profiles and repair them
broken_profiles.each do |profile|! # yes, that's all you need to repair a profile

# or to do the same thing, just more Ruby like
Spaceship::Portal.provisioning_profile.all.find_all { |p| !p.valid? || !p.certificate_valid? }.map(&:repair!)


# Get all enabled devices
all_devices = Spaceship::Portal.device.all

# Disable first device

# Find disabled device and enable it
Spaceship::Portal.device.find_by_udid("44ee59893cb...", include_disabled: true).enable!

# Get list of all devices, including disabled ones, and filter the result to only include disabled devices use enabled? or disabled? methods
disabled_devices = Spaceship::Portal.device.all(include_disabled: true).select do |device|

# or to do the same thing, just more Ruby like with disabled? method
disabled_devices = Spaceship::Portal.device.all(include_disabled: true).select(&:disabled?)

# Register a new device
Spaceship::Portal.device.create!(name: "Private iPhone 6", udid: "5814abb3...")


# Use the InHouse class to get all enterprise certificates
cert = Spaceship::Portal.certificate.in_house.all.first

# Create a new InHouse Enterprise distribution profile
profile = Spaceship::Portal.provisioning_profile.in_house.create!(bundle_id: "com.krausefx.*",
                                                        certificate: cert)

# List all In-House Provisioning Profiles
profiles = Spaceship::Portal.provisioning_profile.in_house.all

Multiple Spaceships

Sometimes one spaceship just isn't enough. That's why this library has its own Spaceship Launcher to launch and use multiple spaceships at the same time 🚀

# Launch 2 spaceships
spaceship1 ="", "password")
spaceship2 ="", "password")

# Fetch all registered devices from spaceship1
devices = spaceship1.device.all

# Iterate over the list of available devices
# and register each device from the first account also on the second one
devices.each do |device|
  spaceship2.device.create!(name:, udid: device.udid)

More cool things you can do

# Find a profile with a specific name
profile = Spaceship::Portal.provisioning_profile.development.all.find { |p| == "Name" }

# Add all available devices to the profile
profile.devices = Spaceship::Portal.device.all

# Push the changes back to the Apple Developer Portal

# Get the currently used team_id

app ="")

# Update app name
app.update_name!('New App Name')

# We generally don't want to be destructive, but you can also delete things
# This method might fail for various reasons, e.g. app is already in the store

Example Data

Some unnecessary information was removed, check out provisioning_profile.rb for all available attributes.

The example data below is a provisioning profile, containing a device, certificate and app.

      @name="Felix iPhone 6",
    >,  ...],
      @name="iOS Distribution",
      @expires=#<DateTime: 2016-02-10T23:44:20>
  @expires=#<DateTime: 2016-02-10T23:44:20>,
  @name=" AppStore",
    @name="App Name",


This project and all fastlane tools are in no way affiliated with Apple Inc. This project is open source under the MIT license, which means you have full access to the source code and can modify it to fit your own needs. All fastlane tools run on your own computer or server, so your credentials or other sensitive information will never leave your own computer. You are responsible for how you use fastlane tools.

You can’t perform that action at this time.